-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/eng 5549 support ensemble runs via python sdk #143
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
Feature/eng 5549 support ensemble runs via python sdk #143
Conversation
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.
This is looking really good, congratulations! Aside from the specific comments, please add the new ensemble.py
to the docs reference. For that there are two changes you need to make:
- In the
mkdocs.yml
file in the root of the repo, add this reference in the appropriate location, which should be under- client.py: nextmv/reference/cloud/client.md
, to keep the alphabetical order. You can simply copy that line and changeclient
forensemble
. - Because you are referencing a non-existent
ensemble.md
file, you need to create it. Add it todocs/nextmv/reference/cloud
. You can copy any of the existing files there, rename it, and modify the content to point to the correct reference::: nextmv.nextmv.cloud.ensemble
.
Basically, whenever we add new files to the SDK, we need to add them to the technical reference of docs as well.
nextmv/nextmv/cloud/application.py
Outdated
endpoint=f"{self.endpoint}/secrets/{secrets_collection_id}", | ||
) | ||
|
||
def delete_ensemble_definition(self, ensemble_definition_id: str) -> None: |
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.
Nit: we try to organize the methods in this class alphabetically, so this one should be above delete_scenario_test
.
nextmv/nextmv/cloud/application.py
Outdated
|
||
def delete_ensemble_definition(self, ensemble_definition_id: str) -> None: | ||
""" | ||
Delete a secrets collection. |
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.
This is not accurate.
nextmv/nextmv/cloud/application.py
Outdated
return False | ||
raise e | ||
|
||
def ensemble_definition(self, ensemble_definition_id: str) -> EnsembleDefinition: |
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.
Nit: same comment about ordering methods alphabetically inside the class.
nextmv/nextmv/cloud/application.py
Outdated
|
||
return [Instance.from_dict(instance) for instance in response.json()] | ||
|
||
def list_ensemble_definitions(self) -> list[EnsembleDefinition]: |
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.
Nit: same comment here about ordering alphabetically.
nextmv/nextmv/cloud/application.py
Outdated
Returns | ||
------- | ||
list['EnsembleDefinition'] |
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.
list['EnsembleDefinition'] | |
list[EnsembleDefinition] |
I think in this case backticks are not needed.
nextmv/nextmv/cloud/application.py
Outdated
---------- | ||
id: str | ||
ID of the ensemble defintion. | ||
name: Optional[str] | ||
Name of the ensemble definition. | ||
description: Optional[str] | ||
Description of the ensemble definition. | ||
run_groups: Optional[list[RunGroup]] | ||
Information to facilitate the execution of child runs. | ||
rules: Optional[list[EvaluationRule]] | ||
Information to facilitate the selection of | ||
a result for the ensemble run from child runs. |
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.
Parameters should be in the same order they are expected in the function arguments.
nextmv/nextmv/cloud/application.py
Outdated
|
||
response = self.client.request( | ||
method="POST", | ||
endpoint=f"{self.endpoint}/ensembles", |
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.
Nit: consider defining ensembles
as an attribute of the class, similar to experiments_endpoint
:
experiments_endpoint: str = "{base}/experiments"
That way, you can use {self.ensembles_endpoint}
as opposed to {self.endpoint}/ensembles
here and in other places.
|
||
return Instance.from_dict(response.json()) | ||
|
||
def update_ensemble_definition( |
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.
Nit: same comment about alphabetical order.
from .batch_experiment import ExperimentStatus as ExperimentStatus | ||
from .client import Client as Client | ||
from .client import get_size as get_size | ||
from .ensemble import EnsembleDefinition as EnsembleDefinition |
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.
Strange, this should be ok.
@cowanwalls You should |
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.
My only leftover request is for this new file to be exposed as reference. Look at the cloud section in the mkdocs.yml index, you should see how to add the file as .md as well. This for docs to be up to date. Would really be awesome to have a dedicated page of a tutorial to handle ensemble definitions and runs in general.
Description
Adds ensemble definition support.
Changes
nextmv/nextmv/cloud/ensemble.py
nextmv/nextmv/cloud/__init__.py
ToleranceType
in acceptance tests and Ensemble runs to a single type? Maybe via the addition of astatatics.py
file innextmv/nextmv/cloud
?nextmv/nextmv/cloud/application.py
new_version
now defaults thename
field to the value ofid
ifname
isNone
(fixes unexpected 404)Testing
Manually tested these changes.