Skip to content

Commit

Permalink
Merge pull request #169 from hpsim/refact/signac_version
Browse files Browse the repository at this point in the history
bump signac versions, see #169
  • Loading branch information
greole authored Dec 30, 2023
2 parents 8f3ea9b + cf7c8a9 commit f77bc51
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ Changelog
- Fix missing of groups in `obr run --list-operations` view, see https://github.com/hpsim/OBR/pull/159.
- Make view folders relative see https://github.com/hpsim/OBR/pull/164
- Use cached version of git repo instead of cloning, see https://github.com/hpsim/OBR/pull/166
- Bump signac version, see https://github.com/hpsim/OBR/pull/169
- Validate simulation state after runSerial|ParallelSolver, see https://github.com/hpsim/OBR/pull/168


0.2.0 (2023-09-14)
------------------
- Add --json=file.json option to obr query, which writes the result of the query to a json file.
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ requires-python = ">=3.6"
dependencies = [
"click",
"PyYAML",
"signac==1.8.0",
"signac-flow==0.23.0",
"signac==2.1.0",
"signac-flow==0.26.1",
"GitPython==3.1.31",
"pandas",
"DeepDiff",
Expand Down
2 changes: 1 addition & 1 deletion src/obr/OpenFOAM/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Union, Generator, Tuple, Any
from pathlib import Path
from subprocess import check_output
from signac.contrib.job import Job
from signac.job import Job
from datetime import datetime
from Owls.parser.FoamDict import FileParser
from Owls.parser.LogFile import LogFile
Expand Down
15 changes: 8 additions & 7 deletions src/obr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
import json
import logging

from signac.contrib.job import Job
from .signac_wrapper.operations import OpenFOAMProject, get_values
from .create_tree import create_tree
from .core.parse_yaml import read_yaml
from .core.queries import input_to_queries, query_impl, build_filter_query, Query
from .core.core import map_view_folder_to_job_id
from signac.job import Job
from pathlib import Path
from subprocess import check_output
from git.repo import Repo
Expand All @@ -38,6 +33,12 @@
from typing import Union, Optional, Any
from copy import deepcopy

from .signac_wrapper.operations import OpenFOAMProject, get_values
from .create_tree import create_tree
from .core.parse_yaml import read_yaml
from .core.queries import input_to_queries, query_impl, build_filter_query, Query
from .core.core import map_view_folder_to_job_id


def check_cli_operations(
project: OpenFOAMProject, operations: list[str], list_operations: Optional[Any]
Expand Down Expand Up @@ -341,7 +342,7 @@ def init(ctx: click.Context, **kwargs):
if kwargs.get("verbose", 0) >= 1:
logging.info(config)

project = OpenFOAMProject.init_project(root=kwargs["folder"])
project = OpenFOAMProject.init_project(path=kwargs["folder"])
create_tree(project, config, kwargs)

logging.info("successfully initialised")
Expand Down
1 change: 1 addition & 0 deletions src/obr/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/usr/bin/env python3
2 changes: 1 addition & 1 deletion src/obr/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from subprocess import check_output
from typing import Union, Generator
from datetime import datetime
from signac.contrib.job import Job
from signac.job import Job
from copy import deepcopy

# these are to be replaced with each other
Expand Down
9 changes: 5 additions & 4 deletions src/obr/core/queries.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from dataclasses import dataclass, field
from typing import Any, Union, Callable, Iterable
from copy import deepcopy
import re
import logging
from signac.contrib.job import Job
import pandas as pd

from dataclasses import dataclass, field
from typing import Any, Union, Callable, Iterable
from copy import deepcopy
from signac.job import Job
from typing import TYPE_CHECKING, Union
from enum import Enum

Expand Down
2 changes: 1 addition & 1 deletion src/obr/create_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from collections.abc import MutableMapping
from pathlib import Path
from subprocess import check_output
from signac.contrib.job import Job
from signac.job import Job
from obr.signac_wrapper.operations import OpenFOAMProject
from copy import deepcopy

Expand Down
4 changes: 2 additions & 2 deletions src/obr/signac_wrapper/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ..core.core import execute
from .labels import owns_mesh, final, finished
from obr.OpenFOAM.case import OpenFOAMCase
from signac.contrib.job import Job
from signac.job import Job
from typing import Union, Literal
from datetime import datetime
import logging
Expand Down Expand Up @@ -111,7 +111,7 @@ def basic_eligible(job: Job, operation: str) -> bool:
def parent_job_is_ready(job: Job) -> str:
"""Checks whether the parent of the given job is ready"""
if job.sp().get("parent_id"):
project = OpenFOAMProject.get_project(root=job.path + "/../..")
project = OpenFOAMProject.get_project(path=job.path + "/../..")
parent_job = project.open_job(id=job.sp().get("parent_id"))
return parent_job.doc["state"].get("global", "")
return ""
Expand Down
10 changes: 5 additions & 5 deletions tests/test_create_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def open_job(self, statepoint):


def test_create_tree(tmpdir, emit_test_config):
project = OpenFOAMProject.init_project(root=tmpdir)
project = OpenFOAMProject.init_project(path=tmpdir)

create_tree(project, emit_test_config, {"folder": tmpdir}, skip_foam_src_check=True)

Expand All @@ -118,7 +118,7 @@ def test_create_tree(tmpdir, emit_test_config):


def test_call_generate_tree(tmpdir, emit_test_config):
project = OpenFOAMProject.init_project(root=tmpdir)
project = OpenFOAMProject.init_project(path=tmpdir)
workspace_dir = tmpdir / "workspace"
view_dir = tmpdir / "view"

Expand Down Expand Up @@ -146,7 +146,7 @@ def test_call_generate_tree(tmpdir, emit_test_config):

def test_cache_folder(tmpdir, emit_test_config):
emit_test_config["case"]["cache_folder"] = f"{tmpdir}/tmp"
project = OpenFOAMProject.init_project(root=tmpdir)
project = OpenFOAMProject.init_project(path=tmpdir)

create_tree(project, emit_test_config, {"folder": tmpdir}, skip_foam_src_check=True)

Expand All @@ -166,8 +166,8 @@ def test_cache_folder(tmpdir, emit_test_config):
# after purgin and recreating the workspace, the cache folder should be used
Path(f"{tmpdir}/tmp/test").touch()
shutil.rmtree(workspace_dir)
os.remove(f"{tmpdir}/signac.rc")
project = OpenFOAMProject.init_project(root=tmpdir)
shutil.rmtree(tmpdir /".signac")
project = OpenFOAMProject.init_project(path=tmpdir)
create_tree(project, emit_test_config, {"folder": tmpdir}, skip_foam_src_check=True)
project.run(names=["fetchCase"])

Expand Down
2 changes: 1 addition & 1 deletion tests/test_md5sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def emit_test_config():


def test_md5sum_calculation(tmpdir, emit_test_config):
project = OpenFOAMProject.init_project(root=tmpdir)
project = OpenFOAMProject.init_project(path=tmpdir)

create_tree(project, emit_test_config, {"folder": tmpdir}, skip_foam_src_check=True)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def get_project(tmpdir):
}
os.chdir(tmpdir)

project = OpenFOAMProject.init_project(root=tmpdir)
project = OpenFOAMProject.init_project(path=tmpdir)
create_tree(project, config, {"folder": tmpdir}, skip_foam_src_check=True)
project.run(names=["fetchCase"])
return project
Expand Down

0 comments on commit f77bc51

Please sign in to comment.