Skip to content

Commit

Permalink
styling
Browse files Browse the repository at this point in the history
  • Loading branch information
amandarichardsonn committed Sep 25, 2024
1 parent b96ac78 commit 959df60
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions smartsim/_core/generation/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import os
import pathlib
import pickle
import time
import subprocess
import sys
import time
import typing as t
from collections import namedtuple
from datetime import datetime
Expand Down Expand Up @@ -175,9 +175,9 @@ def generate_job(self, job: Job, job_index: int) -> Job_Path:
err_file = self._build_err_file_path(log_path, job.entity.name)

Check warning on line 175 in smartsim/_core/generation/generator.py

View check run for this annotation

Codecov / codecov/patch

smartsim/_core/generation/generator.py#L174-L175

Added lines #L174 - L175 were not covered by tests

cmd_list = self._build_commands(job, job_path, log_path)

Check warning on line 177 in smartsim/_core/generation/generator.py

View check run for this annotation

Codecov / codecov/patch

smartsim/_core/generation/generator.py#L177

Added line #L177 was not covered by tests

self._execute_commands(cmd_list)

Check warning on line 179 in smartsim/_core/generation/generator.py

View check run for this annotation

Codecov / codecov/patch

smartsim/_core/generation/generator.py#L179

Added line #L179 was not covered by tests

with open(

Check warning on line 181 in smartsim/_core/generation/generator.py

View check run for this annotation

Codecov / codecov/patch

smartsim/_core/generation/generator.py#L181

Added line #L181 was not covered by tests
self._build_log_file_path(log_path), mode="w", encoding="utf-8"
) as log_file:
Expand Down Expand Up @@ -234,7 +234,7 @@ def _execute_commands(cls, cmd_list: CommandList) -> None:
"""
for cmd in cmd_list:
subprocess.run(cmd.command)

Check warning on line 236 in smartsim/_core/generation/generator.py

View check run for this annotation

Codecov / codecov/patch

smartsim/_core/generation/generator.py#L235-L236

Added lines #L235 - L236 were not covered by tests

@staticmethod
def _mkdir_file(file_path: pathlib.Path) -> Command:
cmd = Command(["mkdir", "-p", str(file_path)])
Expand Down
3 changes: 2 additions & 1 deletion smartsim/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
from smartsim._core import dispatch
from smartsim._core.config import CONFIG
from smartsim._core.control import interval as _interval
from smartsim._core.control import preview_renderer
from smartsim._core.control.launch_history import LaunchHistory as _LaunchHistory
from smartsim._core.utils import helpers as _helpers
from smartsim.error import errors
from smartsim.status import TERMINAL_STATUSES, InvalidJobStatus, JobStatus

from ._core import Generator, Manifest, previewrenderer
from ._core import Generator, Manifest
from ._core.generation.generator import Job_Path
from .entity import TelemetryConfiguration
from .error import SmartSimError
Expand Down
18 changes: 13 additions & 5 deletions tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from smartsim._core.commands import Command, CommandList
from smartsim._core.generation.generator import Generator
from smartsim.builders import Ensemble
from smartsim.entity import Application
from smartsim.entity import entity
from smartsim.entity.files import EntityFiles
from smartsim.launchable import Job
from smartsim.settings import LaunchSettings
Expand All @@ -47,7 +47,7 @@

pytestmark = pytest.mark.group_a

_ID_GENERATOR = (str(i) for i in itertools.count())
ids = set()


_ID_GENERATOR = (str(i) for i in itertools.count())
Expand Down Expand Up @@ -92,7 +92,7 @@ def __init__(self):
self.files = None
self.file_parameters = None

def as_program_arguments(self):
def as_executable_sequence(self):
return ("echo", "Hello", "World!")

def files():
Expand Down Expand Up @@ -226,7 +226,11 @@ def test_build_commands(
"smartsim._core.generation.Generator._write_tagged_files"
) as mock_write_tagged_files,
):
generator_instance._build_commands(mock_job, pathlib.Path(test_dir) / generator_instance.run_directory, pathlib.Path(test_dir) / generator_instance.log_directory)
generator_instance._build_commands(
mock_job,
pathlib.Path(test_dir) / generator_instance.run_directory,
pathlib.Path(test_dir) / generator_instance.log_directory,
)
mock_copy_files.assert_called_once()
mock_symlink_files.assert_called_once()
mock_write_tagged_files.assert_called_once()
Expand All @@ -243,6 +247,7 @@ def test_execute_commands(generator_instance: Generator):
generator_instance._execute_commands(cmd_list)
run_process.assert_called_once()


def test_mkdir_file(generator_instance: Generator, test_dir: str):
"""Test Generator._mkdir_file returns correct type and value"""
cmd = generator_instance._mkdir_file(pathlib.Path(test_dir))
Expand Down Expand Up @@ -385,7 +390,9 @@ def test_generate_ensemble_copy(
jobs_dir = pathlib.Path(test_dir) / run_dir[0] / "jobs"
job_dir = jobs_dir.iterdir()
for ensemble_dir in job_dir:
copy_folder_path = jobs_dir / ensemble_dir / Generator.run_directory / "to_copy_dir"
copy_folder_path = (
jobs_dir / ensemble_dir / Generator.run_directory / "to_copy_dir"
)
assert copy_folder_path.is_dir()
ids.clear()

Expand Down Expand Up @@ -415,6 +422,7 @@ def test_generate_ensemble_symlink(
assert sym_file_path.is_dir()
assert sym_file_path.is_symlink()
assert os.fspath(sym_file_path.resolve()) == osp.realpath(get_gen_symlink_dir)
ids.clear()


def test_generate_ensemble_configure(
Expand Down

0 comments on commit 959df60

Please sign in to comment.