-
Notifications
You must be signed in to change notification settings - Fork 38
Experiment.start Returns Records
#744
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
base: v1.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
|
|
||
| from __future__ import annotations | ||
|
|
||
| import textwrap | ||
| import typing as t | ||
| from copy import deepcopy | ||
|
|
||
|
|
@@ -39,6 +40,7 @@ | |
|
|
||
| if t.TYPE_CHECKING: | ||
| from smartsim.entity.entity import SmartSimEntity | ||
| from smartsim.types import LaunchedJobID | ||
|
|
||
|
|
||
| @t.final | ||
|
|
@@ -158,3 +160,44 @@ | |
| string = f"SmartSim Entity: {self.entity}\n" | ||
| string += f"Launch Settings: {self.launch_settings}" | ||
| return string | ||
|
|
||
|
|
||
| @t.final | ||
| class Record: | ||
| """An object composed of a unique identifier for a launched job, and a copy | ||
| of the job that was launched. | ||
| """ | ||
|
|
||
| def __init__(self, launch_id: LaunchedJobID, job: Job) -> None: | ||
| """Initialize a new record of a launched job | ||
|
|
||
| :param launch_id: A unique identifier for the launch of the job. | ||
| :param job: The job that was launched. | ||
| """ | ||
| self._id = launch_id | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you deep copying the Job but not the launch_id here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory, the There is actually some special logic in TL;DR I was lazy and didn't want to spell out "deepcopy". More than willing to add it though if we think that |
||
| self._job = deepcopy(job) | ||
|
|
||
| @property | ||
| def launched_id(self) -> LaunchedJobID: | ||
| """The unique identifier for the launched job. | ||
|
|
||
| :returns: A unique identifier for the launched job. | ||
| """ | ||
| return self._id | ||
|
|
||
| @property | ||
| def job(self) -> Job: | ||
| """A deep copy of the job that was launched. | ||
MattToast marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| :returns: A deep copy of the launched job. | ||
| """ | ||
| return deepcopy(self._job) | ||
|
|
||
| def __str__(self) -> str: | ||
| return textwrap.dedent(f"""\ | ||
| Launch Record: | ||
| Launched Job ID: | ||
| {self.launched_id} | ||
| Launched Job: | ||
| {textwrap.indent(str(self._job), " ")} | ||
| """) | ||
Uh oh!
There was an error while loading. Please reload this page.