Skip to content
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

Ensemble Move short-task #714

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def _create_applications(self) -> tuple[Application, ...]:
for i, permutation in enumerate(permutations_)
)

def as_jobs(self, settings: LaunchSettings) -> tuple[Job, ...]:
def build_jobs(self, settings: LaunchSettings) -> tuple[Job, ...]:
apps = self._create_applications()
if not apps:
raise ValueError("There are no members as part of this ensemble")
Expand Down
2 changes: 1 addition & 1 deletion smartsim/entity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from .application import Application
from .dbnode import FSNode
from .dbobject import *
from .ensemble import Ensemble
from .._core.builders.ensemble import Ensemble
amandarichardsonn marked this conversation as resolved.
Show resolved Hide resolved
from .entity import SmartSimEntity, TelemetryConfiguration
from .entityList import EntityList, EntitySequence
from .files import TaggedFilesHierarchy
4 changes: 2 additions & 2 deletions smartsim/entity/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@ class CompoundEntity(abc.ABC):
"""

@abc.abstractmethod
def as_jobs(self, settings: LaunchSettings) -> t.Collection[Job]: ...
def build_jobs(self, settings: LaunchSettings) -> t.Collection[Job]: ...
def as_job_group(self, settings: LaunchSettings) -> JobGroup:
return JobGroup(list(self.as_jobs(settings)))
return JobGroup(list(self.build_jobs(settings)))
2 changes: 1 addition & 1 deletion tests/_legacy/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from smartsim._core.control.controller import Controller
from smartsim._core.launcher.step import Step
from smartsim.database.orchestrator import FeatureStore
from smartsim.entity.ensemble import Ensemble
from smartsim._core.builders.ensemble import Ensemble
from smartsim.settings.slurmSettings import SbatchSettings, SrunSettings

controller = Controller()
Expand Down
2 changes: 1 addition & 1 deletion tests/_legacy/test_controller_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from smartsim._core.launcher.step.dragon_step import DragonStep
from smartsim.database import FeatureStore
from smartsim.entity import Application
from smartsim.entity.ensemble import Ensemble
from smartsim._core.builders.ensemble import Ensemble
from smartsim.error import SmartSimError, SSUnsupportedError
from smartsim.error.errors import SSUnsupportedError
from smartsim.settings import RunSettings, SrunSettings
Expand Down
2 changes: 1 addition & 1 deletion tests/_legacy/test_output_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from smartsim._core.launcher.step import Step
from smartsim.database.orchestrator import FeatureStore
from smartsim.entity.application import Application
from smartsim.entity.ensemble import Ensemble
from smartsim._core.builders.ensemble import Ensemble
from smartsim.settings.base import RunSettings
from smartsim.settings.slurmSettings import SbatchSettings, SrunSettings

Expand Down
2 changes: 1 addition & 1 deletion tests/_legacy/test_symlinking.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from smartsim._core.control.controller import Controller, _AnonymousBatchJob
from smartsim.database.orchestrator import FeatureStore
from smartsim.entity.application import Application
from smartsim.entity.ensemble import Ensemble
from smartsim._core.builders.ensemble import Ensemble
from smartsim.settings.base import RunSettings
from smartsim.settings.slurmSettings import SbatchSettings, SrunSettings

Expand Down
14 changes: 7 additions & 7 deletions tests/test_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import pytest

from smartsim.entity.ensemble import Ensemble
from smartsim._core.builders.ensemble import Ensemble
from smartsim.entity.files import EntityFiles
from smartsim.entity.strategies import ParamSet
from smartsim.settings.launch_settings import LaunchSettings
Expand Down Expand Up @@ -109,7 +109,7 @@ def test_ensemble_user_created_strategy(mock_launcher_settings, test_dir):
"echo",
("hello", "world"),
permutation_strategy=user_created_function,
).as_jobs(mock_launcher_settings)
).build_jobs(mock_launcher_settings)
assert len(jobs) == 1


Expand All @@ -125,7 +125,7 @@ def test_ensemble_without_any_members_raises_when_cast_to_jobs(
permutation_strategy="random",
max_permutations=30,
replicas=0,
).as_jobs(mock_launcher_settings)
).build_jobs(mock_launcher_settings)


def test_strategy_error_raised_if_a_strategy_that_dne_is_requested(test_dir):
Expand Down Expand Up @@ -208,7 +208,7 @@ def test_all_perm_strategy(
permutation_strategy="all_perm",
max_permutations=max_perms,
replicas=replicas,
).as_jobs(mock_launcher_settings)
).build_jobs(mock_launcher_settings)
assert len(jobs) == expected_num_jobs


Expand All @@ -222,7 +222,7 @@ def test_all_perm_strategy_contents():
permutation_strategy="all_perm",
max_permutations=16,
replicas=1,
).as_jobs(mock_launcher_settings)
).build_jobs(mock_launcher_settings)
assert len(jobs) == 16


Expand Down Expand Up @@ -262,7 +262,7 @@ def test_step_strategy(
permutation_strategy="step",
max_permutations=max_perms,
replicas=replicas,
).as_jobs(mock_launcher_settings)
).build_jobs(mock_launcher_settings)
assert len(jobs) == expected_num_jobs


Expand Down Expand Up @@ -301,5 +301,5 @@ def test_random_strategy(
permutation_strategy="random",
max_permutations=max_perms,
replicas=replicas,
).as_jobs(mock_launcher_settings)
).build_jobs(mock_launcher_settings)
assert len(jobs) == expected_num_jobs
12 changes: 6 additions & 6 deletions tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_exp_private_generate_method_ensemble(test_dir, wlmutils, generator_inst
"""Test that Job directory was created from Experiment."""
ensemble = Ensemble("ensemble-name", "echo", replicas=2)
launch_settings = LaunchSettings(wlmutils.get_test_launcher())
job_list = ensemble.as_jobs(launch_settings)
job_list = ensemble.build_jobs(launch_settings)
exp = Experiment(name="exp_name", exp_path=test_dir)
for i, job in enumerate(job_list):
job_run_path, _, _ = exp._generate(generator_instance, job, i)
Expand All @@ -239,7 +239,7 @@ def test_exp_private_generate_method_ensemble(test_dir, wlmutils, generator_inst
def test_generate_ensemble_directory(wlmutils, generator_instance):
ensemble = Ensemble("ensemble-name", "echo", replicas=2)
launch_settings = LaunchSettings(wlmutils.get_test_launcher())
job_list = ensemble.as_jobs(launch_settings)
job_list = ensemble.build_jobs(launch_settings)
for i, job in enumerate(job_list):
# Call Generator.generate_job
path, _, _ = generator_instance.generate_job(job, i)
Expand All @@ -263,7 +263,7 @@ def test_generate_ensemble_directory_start(test_dir, wlmutils, monkeypatch):
)
ensemble = Ensemble("ensemble-name", "echo", replicas=2)
launch_settings = LaunchSettings(wlmutils.get_test_launcher())
job_list = ensemble.as_jobs(launch_settings)
job_list = ensemble.build_jobs(launch_settings)
exp = Experiment(name="exp_name", exp_path=test_dir)
exp.start(*job_list)
run_dir = listdir(test_dir)
Expand All @@ -285,7 +285,7 @@ def test_generate_ensemble_copy(test_dir, wlmutils, monkeypatch, get_gen_copy_di
"ensemble-name", "echo", replicas=2, files=EntityFiles(copy=get_gen_copy_dir)
)
launch_settings = LaunchSettings(wlmutils.get_test_launcher())
job_list = ensemble.as_jobs(launch_settings)
job_list = ensemble.build_jobs(launch_settings)
exp = Experiment(name="exp_name", exp_path=test_dir)
exp.start(*job_list)
run_dir = listdir(test_dir)
Expand All @@ -310,7 +310,7 @@ def test_generate_ensemble_symlink(
files=EntityFiles(symlink=get_gen_symlink_dir),
)
launch_settings = LaunchSettings(wlmutils.get_test_launcher())
job_list = ensemble.as_jobs(launch_settings)
job_list = ensemble.build_jobs(launch_settings)
exp = Experiment(name="exp_name", exp_path=test_dir)
exp.start(*job_list)
run_dir = listdir(test_dir)
Expand Down Expand Up @@ -341,7 +341,7 @@ def test_generate_ensemble_configure(
file_parameters=params,
)
launch_settings = LaunchSettings(wlmutils.get_test_launcher())
job_list = ensemble.as_jobs(launch_settings)
job_list = ensemble.build_jobs(launch_settings)
exp = Experiment(name="exp_name", exp_path=test_dir)
id = exp.start(*job_list)
run_dir = listdir(test_dir)
Expand Down
Loading