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
Context.make_with
number of workers interface
#1443
Conversation
Context.make_with
number of workers interface
The ability to do lt.Context.make_with(cpus=4) is really nice in practice! |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1443 +/- ##
==========================================
- Coverage 69.04% 62.32% -6.72%
==========================================
Files 305 305
Lines 17837 17874 +37
Branches 3191 3201 +10
==========================================
- Hits 12315 11140 -1175
- Misses 5019 6287 +1268
+ Partials 503 447 -56
☔ View full report in Codecov by Sentry. |
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.
The ability to do
lt.Context.make_with(cpus=4)is really nice in practice!
Agreed!
This only implements the user-facing part and has some glue code to handle the different cases, the idea being it might be useful to have a working prototype!
I would be very happy to merge this, as soon as we are 100% happy about the user-facing API. I think mostly, the internals will need to change. In #1353 (comment) we do mention "hybrid workers" as a TODO, but I think with the API structure we can implement changes like that as additional keyword arguments, if needed.
Thoughts on actually merging this, pending tests? Maybe having the cases from our design discussion in a testcase? Then, we can replace the implementation bit-by-bit with something proper, without impacting functionality, probably starting with #1353
Thanks @sk1p ! Co-authored-by: Alexander Clausen <alex@gc-web.de>
Thanks for the feedback!
Good point about the hybrid workers, the current interface does explicitly separate the cpu / gpu case. Could potentially have something like: def make_with(
cls,
executor_spec: ExecutorSpecType = 'dask',
*,
cpus: Optional[Union[int, Iterable[int]]] = None,
gpus: Optional[Union[int, Iterable[int]]] = None,
+ hybrids: Optional[int] = None,
plot_class: Optional['Live2DPlot'] = None,
) -> 'Context': I set |
/azp run libertem.libertem-data |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run libertem.libertem-data |
Azure Pipelines successfully started running 1 pipeline(s). |
Building including slow tests here, to hopefully get proper coverage: https://dev.azure.com/LiberTEM/LiberTEM/_build/results?buildId=2372&view=results |
coverage of |
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.
Looks good, generally! Two details about the semantics in the comments.
The current behaviour of For the moment I've hard-coded the executors which are not at all gpu-capable into |
/azp run libertem.libertem-data |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
@uellue said:
I see several scenarios to use these parameters: [...]
I was so free to push a test case implementing these scenarios as code, which passes for me both with GPUs available and without them.
In scenario 4, if we disable all CPU workers but don't have a GPU, shouldn't an error be raised, or was there a warning that I'm missing? This is specifically for the dask executor, which I'm using in the test case, so I can also open a separate issue for this.
Another question, can we add a custom exception type instead of raising a ValueError
? The docs describe the situation as "Raised when an operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception [...]". In this case, if the value is valid depends on the dynamics ("is there a GPU available?") and is closer to a RuntimeError
. Maybe add it to the criminally underused libertem.exceptions
module?
I think other than this, this PR is good to go, and is mainly missing a changelog entry, and updates to the docs. Let me know if I should take a stab at the docs updates.
/azp run libertem.libertem-data |
Azure Pipelines successfully started running 1 pipeline(s). |
Happy to do all of those things, thanks for the suggestions ! |
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! A good sign how short and simple the example became. 👍
/azp run libertem.libertem-data |
Azure Pipelines successfully started running 1 pipeline(s). |
Adds the interface described here: #1353 (comment) to
lt.Context.make_with(..)
.Some of the added code would be temporary until all the executors accept something resembling a
ResourceSpec
created bymake_with
. This only implements the user-facing part and has some glue code to handle the different cases, the idea being it might be useful to have a working prototype!Contributor Checklist:
Reviewer Checklist:
/azp run libertem.libertem-data
passed