Skip to content

Supporting Algo Management API's#18

Merged
besirkurtulmus merged 15 commits into
masterfrom
api-client
Feb 27, 2019
Merged

Supporting Algo Management API's#18
besirkurtulmus merged 15 commits into
masterfrom
api-client

Conversation

@besirkurtulmus

@besirkurtulmus besirkurtulmus commented Feb 26, 2019

Copy link
Copy Markdown
Contributor

The new methods are basically wrapper around the generated python client, that can be found here.

I've added the .create(), .update(), .publish(), .info(), .versions() & .compile() methods under client.algo().

@zeryx zeryx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing too crazy, however much of the work seems to get performed in the algorithmia_api_client. It would be great to have that linked in here so we can see exactly how stuff gets executed.

Comment thread Algorithmia/algorithm.py
if m is not None:
self.client = client
self.path = m.group(1)
self.username = self.path.split("/")[0]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it safe to assume here that the algorithm URI structure will always remain the same? Is there a world where this is brittle(supporting unicode algorithm names/usernames?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume that if the URI structure ever changes, line 19 would also break (which has been part of the client forever now).

Other than that point, I don't think we'll ever change it.

Comment thread Algorithmia/algorithm.py
settingsObj = Settings(**settings)
createRequestVersionInfoObj = CreateRequestVersionInfo(**version_info)
update_parameters = {"details": detailsObj, "settings": settingsObj, "version_info": createRequestVersionInfoObj}
update_request = UpdateRequest(**update_parameters)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit:
Some of your variables are camel case, and some are snake case - I think most of the time you snake case for dicts, but not always. Might be useful to be consistent here.

I think the python default is always snake case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Also as far as I can tell, the client has used both :/

Look at line 19-30. I could change the style for the code I wrote. I personally prefer using underscores. It makes reading the code easier.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per python style guide variables should be snake case:

https://www.python.org/dev/peps/pep-0008/#function-and-variable-names

Comment thread Algorithmia/algorithm.py
Comment thread Algorithmia/algorithm.py
return api_response
except ApiException as e:
error_message = json.loads(e.body)["error"]["message"]
raise ApiError(error_message)

@kennydaniel kennydaniel Feb 27, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way we're handling exceptions is throwing away information. What about the error code, etc? Probably doesn't belong in this PR, but something to think about.

@besirkurtulmus besirkurtulmus merged commit 1560c6b into master Feb 27, 2019
@besirkurtulmus besirkurtulmus deleted the api-client branch February 27, 2019 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants