Skip to content

Commit

Permalink
tests passing ready for merge
Browse files Browse the repository at this point in the history
  • Loading branch information
amandarichardsonn committed Aug 13, 2024
1 parent ff2eaae commit 7c3c546
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
19 changes: 9 additions & 10 deletions smartsim/_core/generation/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,31 @@ def _generate_job_root(self, job: Job, job_index: int) -> pathlib.Path:
return pathlib.Path(job_path)

def _generate_run_path(self, job: Job, job_index: int) -> pathlib.Path:
"""Generates the path for the \"run\" directory within the root directory
"""Generates the path for the "run" directory within the root directory
of a specific Job instance.
:param job (Job): The Job instance for which the path is generated.
:param job_index (int): The index of the Job instance (used for naming).
:returns: The path to the \"run\" directory for the Job instance.
:returns: The path to the "run" directory for the Job instance.
"""
path = self._generate_job_root(job, job_index) / "run"
path.mkdir(exist_ok=False, parents=True)
return pathlib.Path(path)

def _generate_log_path(self, job: Job, job_index: int) -> pathlib.Path:
"""
Generates the path for the \"log\" directory within the root directory of a specific Job instance.
Generates the path for the "log" directory within the root directory of a specific Job instance.
:param job: The Job instance for which the path is generated.
:param job_index: The index of the Job instance (used for naming).
:returns: The path to the \"log\" directory for the Job instance.
:returns: The path to the "log" directory for the Job instance.
"""
path = self._generate_job_root(job, job_index) / "log"
path.mkdir(exist_ok=False, parents=True)
return pathlib.Path(path)

# make this protected
@staticmethod
def log_file(log_path: pathlib.Path) -> pathlib.Path:
def _log_file(log_path: pathlib.Path) -> pathlib.Path:
"""Returns the location of the file
summarizing the parameters used for the generation
of the entity.
Expand All @@ -119,12 +118,12 @@ def generate_job(self, job: Job, job_index: int) -> pathlib.Path:
Tagged application files are read, checked for input variables to
configure, and written. Input variables to configure are
specified with a tag within the input file itself.
The default tag is surronding an input value with semicolons.
The default tag is surrounding an input value with semicolons.
e.g. ``THERMO=;90;``
:param job: The job instance to write and configure files for.
:param job_path: The path to the \"run\" directory for the job instance.
:param log_path: The path to the \"log\" directory for the job instance.
:param job_path: The path to the "run" directory for the job instance.
:param log_path: The path to the "log" directory for the job instance.
"""

# Generate ../job_name/run directory
Expand All @@ -133,7 +132,7 @@ def generate_job(self, job: Job, job_index: int) -> pathlib.Path:
log_path = self._generate_log_path(job, job_index)

# Create and write to the parameter settings file
with open(self.log_file(log_path), mode="w", encoding="utf-8") as log_file:
with open(self._log_file(log_path), mode="w", encoding="utf-8") as log_file:
dt_string = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
log_file.write(f"Generation start date and time: {dt_string}\n")

Expand Down
4 changes: 2 additions & 2 deletions smartsim/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ def start(self, *jobs: Job) -> tuple[LaunchedJobID, ...]:
jobs that can be used to query or alter the status of that
particular execution of the job.
"""
"""Create the run id"""
# Create the run id
run_id = datetime.datetime.now().replace(microsecond=0).isoformat()
"""Generate the root path"""
# Generate the root path
root = pathlib.Path(self.exp_path, run_id)
return self._dispatch(Generator(root), dispatch.DEFAULT_DISPATCHER, *jobs)

Expand Down
2 changes: 1 addition & 1 deletion smartsim/launchable/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def name(self) -> str:
def name(self, name: str) -> None:
"""Sets the name of the Job."""
check_name(name)
logger.info(f'Overwriting the Job name from "{self._name}" to "{name}"')
logger.debug(f'Overwriting the Job name from "{self._name}" to "{name}"')
self._name = name

@property
Expand Down
2 changes: 1 addition & 1 deletion smartsim/launchable/jobGroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def name(self) -> str:
def name(self, name: str) -> None:
"""Sets the name of the JobGroup."""
check_name(name)
logger.info(f'Overwriting Job name from "{self._name}" to "{name}"')
logger.debug(f'Overwriting Job name from "{self._name}" to "{name}"')
self._name = name

@property
Expand Down
2 changes: 1 addition & 1 deletion tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_log_file_path(generator_instance):
"""Test if the log_file function returns the correct log path."""
base_path = "/tmp"
expected_path = osp.join(base_path, "smartsim_params.txt")
assert generator_instance.log_file(base_path) == pathlib.Path(expected_path)
assert generator_instance._log_file(base_path) == pathlib.Path(expected_path)


def test_generate_job_directory(test_dir, wlmutils, generator_instance):
Expand Down

0 comments on commit 7c3c546

Please sign in to comment.