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

Unified task runner scripts #1086

Merged
merged 20 commits into from
Mar 7, 2023
Merged

Unified task runner scripts #1086

merged 20 commits into from
Mar 7, 2023

Conversation

approxit
Copy link
Contributor

@approxit approxit commented Jan 16, 2023

Bucke up folks, massive diff is comming!

What I've done:

  • Unified task runner scripts according to other libraries
  • Bumped mypy version to be able to install other dependencies
  • Added pyproject-autoflake because for some reason at current setup autoflake was not picking up config from pyproject.toml
  • Commented out few flake8 errors and few mypy paths, this should be done as separate work
  • Added __init__.py files into examples and tests to satisfy mypy.
  • Renamed few directories in examples to satisfy mypy (as they are now python packages).

Changes are mostly related to formatting or small fixes such as specifying exception types in except blocks, changing == to is for None values, etc.

@shadeofblue
Copy link
Collaborator

hmm, given that we don't treat the examples as modules but rather self-contained scripts, I'm unsure why we'd need __init__ files in there... ?

@@ -3,10 +3,10 @@
a simple http proxy example
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is the purpose of this name change?

@@ -1,10 +1,10 @@
#!/usr/bin/env python3
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here... these are not modules... the name changes here are neither required nor in any way beneficial... and we risk breaking any links pointing to those examples from any external locations... please, let's not rename them unless we have a very good reason

from yapapi.log import enable_default_logger
from yapapi.payload import vm
from yapapi.rest.activity import BatchTimeoutError
from yapapi import windows_event_loop_fix # noqa: E402
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can probably remove windows_event_loop_fix once we drop support for Python < 3.8

@@ -262,14 +258,15 @@ async def _request_handler(self, request: web.Request) -> web.Response:
return await instance.handle_request(request)

async def run(self):
"""Run a local HTTP server.
Copy link
Collaborator

Choose a reason for hiding this comment

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

well, it's not just any HTTP server...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Run a local HTTP proxy server.

@@ -199,14 +199,14 @@ def __repr__(self):

@property
def app_key(self):
"""The application key used to authorize access to `yagna`'s REST API."""
"""Return the application key used to authorize access to `yagna`'s REST API."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, it's not a function ... it's a property... I believe it should be a noun-like not an action-like...

return (
self.service.cluster.service_runner._job.engine._api_config.app_key # type: ignore[union-attr] # noqa
)

@property
def instance_ws(self):
"""The websocket URI for the specific remote port of the Service."""
"""Return the websocket URI for the specific remote port of the Service."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here...

@@ -181,39 +172,39 @@ async def __aexit__(self, *exc_info) -> None:

@property
def owner_ip(self) -> str:
"""The IP address of the requestor node within the network."""
"""Return the IP address of the requestor node within the network."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

again, these are properties, not methods... their docstrings should reflect that...

@@ -44,27 +42,27 @@ def app_key(self) -> str:

@property
def market_url(self) -> str:
"""The URL of the Market REST API"""
"""Return URL of the Market REST API."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

and again, in case of properties, I believe the docstrings should be formed just as they would be for attributes rather than functions...

Copy link
Collaborator

@shadeofblue shadeofblue left a comment

Choose a reason for hiding this comment

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

Please revert the directory name changes in the examples part... unless there's a critical reason to do that

Otherwise, I strongly believe the properties' docstrings should be phrased just as they would be in case of regular attributes rather than functions -> especially that once you receive them, they behave so -> you cannot call them for them to perform their function, you get what the docstring says you'd get, so, e.g.

@approxit
Copy link
Contributor Author

approxit commented Feb 9, 2023

Regarding __init__.py in examples and tests, I've commented at the very begining that it was added to satisfy mypy, because it encounter errors about loading files without __init__.py. I could reconfigure mypy to check specific list of directories, instead of whole codebase.

Regarding property docs - change was made to satisfy pydocstyle - should we fight with this?

Copy link
Collaborator

@shadeofblue shadeofblue left a comment

Choose a reason for hiding this comment

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

okay, let's say it looks good...

I'd still strongly prefer the properties' docs to be specified using noun-like constructs and not action-like ones but I don't feel this is worth arguing about...

@approxit approxit merged commit ae04684 into master Mar 7, 2023
@approxit approxit deleted the unify-tasks-across-repos branch March 7, 2023 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants