-
Notifications
You must be signed in to change notification settings - Fork 22
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
Usage reporting tweaks #536
Conversation
parser.add_argument("--num-instances", type=int, default=1, help="The number of instances of the service to spawn") | ||
parser.add_argument("--show-usage", action="store_true", help="Show usage and cost of each instance while running.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done ;)
@@ -39,9 +39,10 @@ class SimpleService(Service): | |||
SIMPLE_SERVICE = "/golem/run/simple_service.py" | |||
SIMPLE_SERVICE_CTL = "/golem/run/simulate_observations_ctl.py" | |||
|
|||
def __init__(self, *args, instance_name, **kwargs): | |||
def __init__(self, *args, instance_name, show_usage: bool = False, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd either specify types for both instance_name
and show_usage
, or for neither of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, here, done ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice :) I have a number of very minor comments (basically just what a linter would report), but I'd like to hear your opinion on putting some more common code in the examples/utils.py
module.
from dataclasses import dataclass, field | ||
from datetime import timedelta, datetime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should go before import enum
yapapi/ctx.py
Outdated
async def get_usage(self): | ||
async def get_raw_usage(self) -> yaa_ActivityUsage: | ||
"""Get the raw usage vector for the activity bound to this work context. | ||
The value comes directly from the low level API and is not interpreted in any way.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a multi-line docstring, there should be a blank line after the first (summary) line, see https://www.python.org/dev/peps/pep-0257/#multi-line-docstrings.
Also I think the prevailing convention in yapapi
docstrings is to put the closing """
on a new line in multi-line docstrings.
yapapi/ctx.py
Outdated
"""Get the state activity bound to this work context. | ||
The value comes directly from the low level API and is not interpreted in any way.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my remark above about multi-line docstring formatting.
yapapi/utils.py
Outdated
@@ -2,6 +2,7 @@ | |||
import asyncio | |||
import logging | |||
from typing import AsyncContextManager, Callable, Optional | |||
from datetime import datetime, timezone, tzinfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep imports sorted according to alphabetic ordering of module names
let's just add a linter to our test runs? ... maybe as a non-required step? ;)... |
Let's, we have an issue for that: #334 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
No description provided.