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

Missing docstrings for public classes and methods #416

Merged
merged 10 commits into from
Jun 2, 2021

Conversation

azawlocki
Copy link
Contributor

@azawlocki azawlocki commented May 31, 2021

@azawlocki azawlocki requested a review from a team May 31, 2021 15:01
@azawlocki azawlocki force-pushed the az/service-api-docstrings branch from 9eb53f6 to a7889be Compare May 31, 2021 15:56
@azawlocki azawlocki requested review from kmazurek and shadeofblue May 31, 2021 15:57
@azawlocki azawlocki self-assigned this May 31, 2021
yapapi/executor/__init__.py Outdated Show resolved Hide resolved
yapapi/executor/__init__.py Outdated Show resolved Hide resolved
@@ -124,6 +128,8 @@ def unpack_work_item(item: WorkItem) -> Tuple[Work, ExecOptions]:


class Golem(AsyncContextManager):
"""Base execution engine containing functions common to all modes of operation."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this has become our main entry point class for the API I'd consider including a bit more information about it here (e.g. the fact it is considered a main entry point, mention it's usually a good idea to have a single instance in the agent code, how and why it can be used as a context manager etc.). This is just a suggestion though, not a change request.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, it would be a good idea to include a wider description and an example usage perhaps but indeed, it definitely could be a separate pull request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree but decided to leave it for a separate PR, as suggested by @shadeofblue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A follow-up issue: #425

yapapi/executor/__init__.py Show resolved Hide resolved
yapapi/executor/__init__.py Outdated Show resolved Hide resolved
yapapi/executor/__init__.py Outdated Show resolved Hide resolved
:param worker: an async generator that takes a `WorkContext` object and a sequence
of tasks, and generates as sequence of work items to be executed on providers in order
to compute given tasks
:param data: an iterator of `Task` objects to be computed on providers
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
:param data: an iterator of `Task` objects to be computed on providers
:param data: an iterator or generator of `Task` objects to be computed on providers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in 761f820

@shadeofblue btw, we should probably rename this parameter to tasks, data is weird

"""Run a number of instances of a service represented by a given `Service` subclass.

:param service_class: a subclass of `Service` that represents the service to be run
:param num_instances: the number of service instances to run
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
:param num_instances: the number of service instances to run
:param num_instances: optional number of service instances to run, defaults to a single instance if not given

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in 761f820

:param num_instances: the number of service instances to run
:param payload: optional runtime definition for the service; if not provided, the
payload specified by the `get_payload()` method of `service_class` is used
:param expiration:optional expiration date for the service
Copy link
Contributor

@shadeofblue shadeofblue Jun 1, 2021

Choose a reason for hiding this comment

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

Suggested change
:param expiration:optional expiration date for the service
:param expiration: optional expiration datetime for the service

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in 761f820

@@ -907,29 +969,34 @@ def __init__(

@property
def driver(self) -> str:
"""Return the payment driver used for this `Executor`'s engine."""
Copy link
Contributor

Choose a reason for hiding this comment

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

just a thought - is this still required here? (apart from backwards-compatibility) ? ... maybe we should add @deprecated here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's still used in blender-deprecated.py, a version of our Blender example that uses the Executor interface.
We probably don't need to deprecate it separately from the whole Executor class.

return self._engine.driver

@property
def network(self) -> str:
"""Return the payment network used for this `Executor`'s engine."""
Copy link
Contributor

Choose a reason for hiding this comment

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

just a thought - is this still required here? (apart from backwards-compatibility) ? ... maybe we should add @deprecated here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's still used in blender-deprecated.py, a version of our Blender example that uses the Executor interface.
We probably don't need to deprecate it separately from the whole Executor class.


@property
def id(self):
"""Return the id of the work context associated with this service instance."""
Copy link
Contributor

@shadeofblue shadeofblue Jun 1, 2021

Choose a reason for hiding this comment

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

well, I'm unsure - my thought here was that it would be "an identifier of an instance" and it would an internal implementation detail that it's - effectively - equal to the id of the respective work context ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in 761f820

Copy link
Contributor

@kmazurek kmazurek left a comment

Choose a reason for hiding this comment

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

Great work!

@azawlocki azawlocki merged commit 3935f28 into master Jun 2, 2021
@azawlocki azawlocki deleted the az/service-api-docstrings branch June 2, 2021 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants