Skip to content

Commit

Permalink
Merge pull request #36 from DLHub-Argonne/feature-run-name
Browse files Browse the repository at this point in the history
Changing .run(author, name, data) to .run(name, data)
  • Loading branch information
WardLT committed Jan 30, 2019
2 parents 45ee1de + 5cee894 commit 8d0a218
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ That command will return a Pandas DataFrame of models, which looks something lik
Once you get the name of a model, it can be run thorugh the client as well:

```python
client.run(author='ryan_globusid' name='noop', inputs='my data')
client.run('ryan_globusid/noop', inputs='my data')
```

### Publishing a Model
Expand Down
7 changes: 3 additions & 4 deletions dlhub_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,19 @@ def describe_servable(self, author, name):
serv = df_tmp.query('name={name} AND author={author}'.format(name=name, author=author))
return serv.iloc[0]

def run(self, author, name, inputs, input_type='python'):
def run(self, name, inputs, input_type='python'):
"""Invoke a DLHub servable
Args:
author (string): Username of the owner of a servable
name (string): Name of the servable
name (string): DLHub name of the model of the form <user>/<model_name>
inputs: Data to be used as input to the function. Can be a string of file paths or URLs
input_type (string): How to send the data to DLHub. Can be "python" (which pickles
the data), "json" (which uses JSON to serialize the data), or "files" (which
sends the data as files).
Returns:
Reply from the service
"""
servable_path = 'servables/{author}/{name}/run'.format(author=author, name=name)
servable_path = 'servables/{name}/run'.format(name=name)

# Prepare the data to be sent to DLHub
if input_type == 'python':
Expand Down
4 changes: 2 additions & 2 deletions dlhub_sdk/tests/test_dlhub_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def test_run(self):
data = {"data": ["V", "Co", "Zr"]}

# Test sending the data as JSON
res = self.dl.run(user, name, data, input_type='json')
res = self.dl.run("{}/{}".format(user, name), data, input_type='json')
self.assertEqual({}, res)

# Test sending the data as pickle
res = self.dl.run(user, name, data, input_type='python')
res = self.dl.run("{}/{}".format(user, name), data, input_type='python')
self.assertEqual({}, res)

def test_submit(self):
Expand Down

0 comments on commit 8d0a218

Please sign in to comment.