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

summon api: call python code from the user side #3079

Closed
3 tasks
dmpetrov opened this issue Jan 7, 2020 · 3 comments
Closed
3 tasks

summon api: call python code from the user side #3079

dmpetrov opened this issue Jan 7, 2020 · 3 comments
Labels
discussion requires active participation to reach a conclusion feature request Requesting a new feature

Comments

@dmpetrov
Copy link
Member

dmpetrov commented Jan 7, 2020

In the current implementation, the calling python function has to be specified in the repo:

dvcsummon.yaml:

objects:
  - name: sea_ice
    summon:
        type: python
        call: myfunc
        deps: ['sea_ice.csv']

And the function has to be in the repo. Otherwise it does not work:

>>> import dvc.api
>>> def myfunc(): print("hello myfunc!!!")
>>> df = dvc.api.summon('sea_ice', 'https://github.com/iterative/df_sea_ice_no_header', rev='dmpetrov-patch-1')
...
ModuleNotFoundError: No module named 'myfunc'

We need to have an ability for the user to call his own code and specify the function name on his own code. Like this:

>>> import dvc.api
>>> def myfunc(): print("hello myfunc!!!")
>>> df = dvc.api.summon('sea_ice', 'https://github.com/iterative/df_sea_ice_no_header', rev='dmpetrov-patch-1', call=myfunc)
hello myfunc!!!

Or like in the initial issue #2719 description:

    name: some_dataframe
    call: pandas.read_csv
  • Define function in user code.
  • Specify function name in user's code (dvc.api.summon() not in dvcsummon.yaml)
  • Pass parameters (and probably parsed yaml object)
@dmpetrov dmpetrov added the bug Did we break something? label Jan 7, 2020
@Suor
Copy link
Contributor

Suor commented Jan 7, 2020

What's the point? Get an artifact, i.e. a file, and then pass it to your function, no need for all these complications and the inversion of control.

@efiop efiop added discussion requires active participation to reach a conclusion feature request Requesting a new feature and removed bug Did we break something? labels Jan 7, 2020
@Suor
Copy link
Contributor

Suor commented Jan 9, 2020

@dmpetrov you mentioned you have some use case during Retro. Can you post it here?

@dberenbaum
Copy link
Collaborator

Closing as stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion requires active participation to reach a conclusion feature request Requesting a new feature
Projects
None yet
Development

No branches or pull requests

4 participants