Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapper for Python functions #793

Open
PythonFZ opened this issue May 6, 2024 · 0 comments
Open

Wrapper for Python functions #793

PythonFZ opened this issue May 6, 2024 · 0 comments
Labels
enhancement New feature or request p3-nice-to-have

Comments

@PythonFZ
Copy link
Member

PythonFZ commented May 6, 2024

If you want to do something like:

class MyNode:
    self.inputs = zntrack.deps()
   
    def run(self):
        self.data = sum(self.inputs)
        

class Linspace(zntrack.Node):
    args: tuple = zntrack.params()
    results = zntrack.outs()

   def run(self):
        self.results = np.linspace(*args)


MyNode(inputs=Linspace(args=(0,1,100)))

this could be simplified to

zn_linspace = zntrack.nodify(np.linspace) # or zntrack.convert, idk
MyNode(inputs=zn_linspace(0, 1, 100))

This would only work if:

  • the function can be imported
  • inputs and outputs are somewhat uniform

and would create

class Linspace(zntrack.Node):
   args: tuple = zntrack.params()
   kwargs: dict = zntrack.param()

   results: any = zntrack.outs()

   def run(self):
       self.results = np.linspace(*args, **kwargs)
@PythonFZ PythonFZ added enhancement New feature or request p3-nice-to-have labels May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p3-nice-to-have
Projects
None yet
Development

No branches or pull requests

1 participant