Matgenix / jobflow-remote

jobflow-remote is a Python package to run jobflow workflows on remote resources.
https://matgenix.github.io/jobflow-remote/
Other
25 stars 11 forks source link

Question about supported data types #44

Closed Andrew-S-Rosen closed 10 months ago

Andrew-S-Rosen commented 10 months ago

Hi friends. What are the supported data types for dispatched functions in terms of the args/kwargs? Typical MSONable? I'm curious if passing a function as a keyword argument would be possible. Disclaimer: I haven't actually used jobflow-remote yet, so apologies if this is obvious once I do start to try it out.

Something like the following toy example (obviously one would never need to write it this way for such a simple example):

# mymodule

def add(a: float, b: float) -> float:
    return a + b

def mult(a: float, b: float) -> float:
    return a * b
from jobflow import job
from mymodule import add, mult

@job
def my_job(a: float, b: float, op: callable = add) -> float:
    return op(a, b)

my_job(a, b, op=mult)
davidwaroquiers commented 10 months ago

Hi @Andrew-S-Rosen

Indeed I believe it won't work (not necessarily due to jobflow-remote). It would indeed be a good addition but I think it should be within jobflow itself (or maybe monty MSONable ? not sure if that would be so easy ?). Typical args and kwargs are currently indeed MSONable objects.

Regarding jobflow-remote itself, if you'd like to have a call to have a quick demo, don't hesitate to reach out :)

utf commented 10 months ago

There is already support for this in jobflow... I made callable functions msonable in monty in these PRs:

davidwaroquiers commented 10 months ago

Nice! I wasn't aware of that (or maybe forgot). Then it should also work in jobflow-remote but we should probably test this specifically just to be sure.

Andrew-S-Rosen commented 10 months ago

This just made me so happy. Thank you both!! I had assumed it wasn't MSONable, but it looks like you already took care of that, @utf. Beautiful!!