-
Notifications
You must be signed in to change notification settings - Fork 38
Job and MPMD Job Implementation #603
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a2b58af
WIP
6bcd4e5
job class and mpmd job in progress
4e01283
Merge branch 'jobclass' of https://github.com/juliaputko/SmartSim int…
ad541a1
Merge branch 'develop' of https://github.com/CrayLabs/SmartSim into j…
b3b1326
addressing review comments
88a98cd
Update mpmdjob.py
juliaputko daee658
Update mpmdjob.py
juliaputko c0998eb
Update job.py
juliaputko 529b072
Update job.py
juliaputko 0d3a052
Update job.py
juliaputko 335500e
Update basejob.py
juliaputko d7e8968
Update job.py
juliaputko 11d0f23
Update mpmdjob.py
juliaputko e2d3231
Update mpmdjob.py
juliaputko 6610113
Update mpmdpair.py
juliaputko 0148606
changes to tests and mpmdjob.py
064b93e
Merge branch 'smartsim-refactor' of https://github.com/CrayLabs/Smart…
658795a
orch-> fs and model-> appl
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # BSD 2-Clause License | ||
| # | ||
| # Copyright (c) 2021-2024, Hewlett Packard Enterprise | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # | ||
| # 1. Redistributions of source code must retain the above copyright notice, this | ||
| # list of conditions and the following disclaimer. | ||
| # | ||
| # 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| from .basejob import BaseJob | ||
| from .job import Job | ||
| from .launchable import Launchable | ||
| from .mpmdjob import MPMDJob | ||
| from .mpmdpair import MPMDPair |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # BSD 2-Clause License | ||
| # | ||
| # Copyright (c) 2021-2024, Hewlett Packard Enterprise | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # | ||
| # 1. Redistributions of source code must retain the above copyright notice, this | ||
| # list of conditions and the following disclaimer. | ||
| # | ||
| # 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
|
|
||
| from abc import ABC, abstractmethod | ||
|
|
||
| from smartsim.launchable.launchable import Launchable | ||
|
|
||
|
|
||
| class BaseJob(ABC, Launchable): | ||
| """The highest level abstract base class for a single job that can be launched""" | ||
|
|
||
| @abstractmethod | ||
| def get_launch_steps(self) -> None: # TODO: -> LaunchSteps: | ||
| """Return the launch steps corresponding to the | ||
| internal data. | ||
| """ | ||
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # BSD 2-Clause License | ||
| # | ||
| # Copyright (c) 2021-2024, Hewlett Packard Enterprise | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # | ||
| # 1. Redistributions of source code must retain the above copyright notice, this | ||
| # list of conditions and the following disclaimer. | ||
| # | ||
| # 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| from abc import abstractmethod | ||
| from copy import deepcopy | ||
|
|
||
| from smartsim.entity.entity import SmartSimEntity | ||
| from smartsim.launchable.basejob import BaseJob | ||
| from smartsim.settings import RunSettings | ||
|
|
||
|
|
||
| class Job(BaseJob): | ||
| """A Job holds a reference to a SmartSimEntity and associated | ||
| LaunchSettings prior to launch. It is responsible for turning | ||
| the stored entity and launch settings into commands that can be | ||
| executed by a launcher. | ||
|
|
||
| Jobs will hold a deep copy of launch settings. | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| entity: SmartSimEntity, | ||
| launch_settings: RunSettings, # TODO: rename to LaunchSettings | ||
| ) -> None: | ||
| super().__init__() | ||
| self._entity = deepcopy(entity) | ||
| self._launch_settings = deepcopy(launch_settings) | ||
| # TODO: self.warehouse_runner = JobWarehouseRunner | ||
|
|
||
| @property | ||
| def entity(self) -> SmartSimEntity: | ||
| return deepcopy(self._entity) | ||
|
|
||
| @entity.setter | ||
| def entity(self, value): | ||
| self._entity = deepcopy(value) | ||
|
|
||
| @property | ||
| def launch_settings(self) -> RunSettings: | ||
| return deepcopy(self._launch_settings) | ||
|
|
||
| @launch_settings.setter | ||
| def launch_settings(self, value): | ||
| self._launch_settings = deepcopy(value) | ||
|
|
||
| def get_launch_steps(self) -> None: # -> LaunchCommands: | ||
| """Return the launch steps corresponding to the | ||
| internal data. | ||
| """ | ||
| pass | ||
| # TODO: return JobWarehouseRunner.run(self) | ||
|
|
||
| def __str__(self) -> str: # pragma: no cover | ||
| string = f"SmartSim Entity: {self.entity}\n" | ||
| string += f"Launch Settings: {self.launch_settings}" | ||
| return string | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # BSD 2-Clause License | ||
| # | ||
| # Copyright (c) 2021-2024, Hewlett Packard Enterprise | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # | ||
| # 1. Redistributions of source code must retain the above copyright notice, this | ||
| # list of conditions and the following disclaimer. | ||
| # | ||
| # 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
|
|
||
| class SmartSimObject: | ||
| """Base Class for SmartSim Objects""" | ||
|
|
||
| ... | ||
|
|
||
|
|
||
| class Launchable(SmartSimObject): | ||
| """Base Class for anything than can be passed | ||
| into Experiment.start()""" | ||
|
|
||
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # BSD 2-Clause License | ||
| # | ||
| # Copyright (c) 2021-2024, Hewlett Packard Enterprise | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # | ||
| # 1. Redistributions of source code must retain the above copyright notice, this | ||
| # list of conditions and the following disclaimer. | ||
| # | ||
| # 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| import typing as t | ||
| from copy import deepcopy | ||
|
|
||
| from smartsim.entity.entity import SmartSimEntity | ||
| from smartsim.error.errors import SSUnsupportedError | ||
| from smartsim.launchable.basejob import BaseJob | ||
| from smartsim.launchable.mpmdpair import MPMDPair | ||
| from smartsim.settings.base import RunSettings | ||
|
|
||
|
|
||
| def _check_launcher(mpmd_pairs: t.List[MPMDPair]) -> None: | ||
| """Enforce all pairs have the same launcher""" | ||
| flag = 0 | ||
| ret = None | ||
| for mpmd_pair in mpmd_pairs: | ||
| if flag == 1: | ||
| if ret == mpmd_pair.launch_settings.run_command: | ||
| flag = 0 | ||
| else: | ||
| raise SSUnsupportedError("MPMD pairs must all share the same launcher.") | ||
| ret = mpmd_pair.launch_settings.run_command | ||
| flag = 1 | ||
|
|
||
|
|
||
| def _check_entity(mpmd_pairs: t.List[MPMDPair]) -> None: | ||
| """Enforce all pairs have the same entity types""" | ||
| flag = 0 | ||
| ret = None | ||
| for mpmd_pair in mpmd_pairs: | ||
| if flag == 1: | ||
| if type(ret) == type(mpmd_pair.entity): | ||
| flag = 0 | ||
| else: | ||
| raise SSUnsupportedError( | ||
| "MPMD pairs must all share the same entity type." | ||
| ) | ||
| ret = mpmd_pair.entity | ||
| flag = 1 | ||
|
|
||
|
|
||
| class MPMDJob(BaseJob): | ||
| """An MPMDJob holds references to SmartSimEntity and | ||
| LaunchSettings pairs. It is responsible for turning | ||
| The stored pairs into an MPMD command(s) | ||
| """ | ||
|
|
||
| def __init__(self, mpmd_pairs: t.List[MPMDPair] = None) -> None: | ||
| super().__init__() | ||
| self._mpmd_pairs = deepcopy(mpmd_pairs) if mpmd_pairs else [] | ||
| _check_launcher(self._mpmd_pairs) | ||
| _check_entity(self._mpmd_pairs) | ||
| # TODO: self.warehouse_runner = MPMDJobWarehouseRunner | ||
|
|
||
| @property | ||
| def mpmd_pairs(self) -> t.List[MPMDPair]: | ||
| return deepcopy(self._mpmd_pairs) | ||
|
|
||
| @mpmd_pairs.setter | ||
| def mpmd_pair(self, value): | ||
| self._mpmd_pair = deepcopy(value) | ||
|
|
||
| def add_mpmd_pair( | ||
| self, entity: SmartSimEntity, launch_settings: RunSettings | ||
| ) -> None: | ||
| """ | ||
| Add a mpmd pair to the mpmd job | ||
| """ | ||
| self._mpmd_pairs.append(MPMDPair(entity, launch_settings)) | ||
| _check_launcher(self.mpmd_pairs) | ||
| _check_entity(self.mpmd_pairs) | ||
|
|
||
| def get_launch_steps(self) -> None: # TODO: -> LaunchSteps: | ||
| """Return the launch steps corresponding to the | ||
| internal data. | ||
| """ | ||
| pass | ||
| # TODO: return MPMDJobWarehouseRunner.run(self) | ||
|
|
||
| def __str__(self) -> str: # pragma: no cover | ||
| """returns A user-readable string of a MPMD Job""" | ||
| for mpmd_pair in self.mpmd_pairs: | ||
| string = "\n== MPMD Pair == \n{}\n{}\n" | ||
| return string.format(mpmd_pair.entity, mpmd_pair.launch_settings) | ||
| return string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # BSD 2-Clause License | ||
| # | ||
| # Copyright (c) 2021-2024, Hewlett Packard Enterprise | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # | ||
| # 1. Redistributions of source code must retain the above copyright notice, this | ||
| # list of conditions and the following disclaimer. | ||
| # | ||
| # 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| from smartsim.entity.entity import SmartSimEntity | ||
| from smartsim.settings.base import RunSettings | ||
|
|
||
|
|
||
| class MPMDPair: | ||
juliaputko marked this conversation as resolved.
Show resolved
Hide resolved
juliaputko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """Class to store MPMD Pairs""" | ||
|
|
||
| def __init__( | ||
| self, entity: SmartSimEntity, launch_settings: RunSettings | ||
| ): # TODO: rename to LaunchSettings | ||
| self.entity = entity | ||
| self.launch_settings = launch_settings | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.