Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
“Dafydd committed Sep 13, 2024
1 parent 60c48e1 commit 58b621c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
21 changes: 11 additions & 10 deletions cstar/base/additional_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ class AdditionalCode:
Verify whether the files associated with this AdditionalCode instance can be found at `local_dir`
"""

def __init__(self,
base_model: BaseModel,
location: str,
subdir: str = "",
checkout_target: Optional[str] = None,
source_mods: Optional[List[str]] = None,
namelists: Optional[List[str]] = None,
def __init__(
self,
base_model: BaseModel,
location: str,
subdir: str = "",
checkout_target: Optional[str] = None,
source_mods: Optional[List[str]] = None,
namelists: Optional[List[str]] = None,
):
"""
Initialize an AdditionalCode object from a DataSource and a list of code files
Expand Down Expand Up @@ -177,7 +178,7 @@ def get(self, local_dir: str | Path) -> None:
(self.source.source_type == "directory")
or (self.source.source_type == "repository")
):
source_dir = Path(self.source.location)/self.subdir
source_dir = Path(self.source.location) / self.subdir

else:
raise ValueError(
Expand All @@ -195,11 +196,11 @@ def get(self, local_dir: str | Path) -> None:

if file_list is None:
continue
(local_dir/file_type).mkdir(parents=True, exist_ok=True)
(local_dir / file_type).mkdir(parents=True, exist_ok=True)

for f in file_list:
src_file_path = source_dir / f
tgt_file_path = local_dir / file_type/ Path(f).name
tgt_file_path = local_dir / file_type / Path(f).name
print(f"copying {src_file_path} to {tgt_file_path}")
if src_file_path.exists():
shutil.copy(src_file_path, tgt_file_path)
Expand Down
4 changes: 3 additions & 1 deletion cstar/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,9 @@ def setup(self) -> None:

# Get AdditionalCode
if component.additional_code is not None:
component.additional_code.get(self.caseroot/"additional_code"/component.base_model.name)
component.additional_code.get(
self.caseroot / "additional_code" / component.base_model.name
)

# Get InputDatasets
# tgt_dir=self.caseroot+'/input_datasets/'+component.base_model.name
Expand Down
6 changes: 5 additions & 1 deletion cstar/roms/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def run(
self,
n_time_steps: Optional[int] = None,
account_key: Optional[str] = None,
output_dir: Optional[str] = None,
output_dir: Optional[str | Path] = None,
walltime: Optional[str] = _CSTAR_SYSTEM_MAX_WALLTIME,
job_name: str = "my_roms_run",
) -> None:
Expand Down Expand Up @@ -264,6 +264,10 @@ def run(
)
if output_dir is None:
output_dir = self.exe_path.parent
output_dir = Path(output_dir)

# Set run path to output dir for clarity: we are running in the output dir but
# these are conceptually different:
run_path = output_dir

if self.additional_code is None:
Expand Down

0 comments on commit 58b621c

Please sign in to comment.