Skip to content

Commit

Permalink
styling
Browse files Browse the repository at this point in the history
  • Loading branch information
amandarichardsonn committed Aug 7, 2024
1 parent 907a1d0 commit 69c9f2d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
15 changes: 9 additions & 6 deletions smartsim/_core/generation/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ class Generator:
"""

def __init__(self, root: os.PathLike[str]) -> None:
"""Initialize a generator object
"""Initialize a Generator object
TODO The Generator class is responsible for creating Job directories.
It ensures that paths adhere to SmartSim path standards. Additionally,
it creates a run directory to handle symlinking,
configuration, and file copying to the job directory.
The class handles symlinking, copying, and configuration of files
associated with a Jobs entity. Additionally, it writes entity parameters
used for the specific run into the "smartsim_params.txt" settings file within
the Jobs log folder.
"""
self.root = root
"""The root path under which to generate files"""
Expand Down Expand Up @@ -102,7 +102,7 @@ def generate_job(

def _build_operations(self, job: Job, job_path: os.PathLike[str]) -> None:
"""This method orchestrates file system ops for the attached SmartSim entity.
It processes three types of file system ops: to_copy, to_symlink, and to_configure.
It processes three types of file system operations: to_copy, to_symlink, and to_configure.
For each type, it calls the corresponding private methods that open a subprocess
to complete each task.
Expand All @@ -126,8 +126,11 @@ def _copy_files(files: t.Union[EntityFiles, None], dest: os.PathLike[str]) -> No
return
for src in files.copy:
if os.path.isdir(src):
# Remove basename of source
base_source_name = os.path.basename(src)
# Attach source basename to destination
new_dst_path = os.path.join(dest, base_source_name)
# Copy source contents to new destination path
subprocess.run(
args=[
sys.executable,
Expand Down
1 change: 0 additions & 1 deletion smartsim/_core/launcher/dragon/dragonLauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ def _as_run_request_args_and_policy(
# this will need to be injected by the user or by us to have
# the command execute next to any generated files. A similar
# problem exists for the other settings.
# TODO: Find a way to inject this path
path=path,
env=env,
# TODO: Not sure how this info is injected
Expand Down
1 change: 0 additions & 1 deletion smartsim/entity/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ def __init__(self, name: str, run_settings: "RunSettings") -> None:
share these attributes.
:param name: Name of the entity
:param path: path to output, error, and configuration files
"""
self.name = name
self.run_settings = run_settings
Expand Down
8 changes: 3 additions & 5 deletions smartsim/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ def start(self, *jobs: Job) -> tuple[LaunchedJobID, ...]:
particular execution of the job.
"""
run_id = datetime.datetime.now().replace(microsecond=0).isoformat()
"""Create the run id"""
root = pathlib.Path(self.exp_path, run_id)
"""Create the run id for Experiment.start"""
"""Generate the root path"""
return self._dispatch(Generator(root), dispatch.DEFAULT_DISPATCHER, *jobs)

def _dispatch(
Expand Down Expand Up @@ -248,16 +249,13 @@ def _generate(
) -> os.PathLike[str]:
"""Generate the directory and file structure for a ``Job``
``Experiment._generate`` calls the appropriate Generator
function to create a directory for the passed job.
If files or directories are attached to an ``application`` object
associated with the Job using ``application.attach_generator_files()``,
those files or directories will be symlinked, copied, or configured and
written into the created job directory
An instance of ``Generator`` and ``Job`` can be passed as an argument to
the protected _generate member.
the protected _generate member, as well as the Jobs index.
:param generator: The generator is responsible for creating the job run and log directory.
:param job: The job instance for which the output is generated.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def test_generate_copy_directory(wlmutils, get_gen_copy_dir, generator_instance)
log_path = generator_instance.root / "log"
log_path.mkdir(parents=True)
generator_instance.generate_job(job, run_path, log_path)
expected_file = run_path / "to_copy_dir"
assert osp.isdir(expected_file)
expected_folder = run_path / "to_copy_dir"
assert osp.isdir(expected_folder)


def test_generate_symlink_directory(wlmutils, generator_instance, get_gen_symlink_dir):
Expand Down

0 comments on commit 69c9f2d

Please sign in to comment.