Skip to content

Commit 1649080

Browse files
committed
..
1 parent f700fd9 commit 1649080

File tree

4 files changed

+83
-76
lines changed

4 files changed

+83
-76
lines changed

petab/v2/__init__.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55

66
from warnings import warn
77

8-
# TODO: remove v1 star imports
9-
from ..v1.calculate import * # noqa: F403, F401, E402
10-
from ..v1.composite_problem import * # noqa: F403, F401, E402
11-
from ..v1.core import * # noqa: F403, F401, E402
12-
from ..v1.format_version import __format_version__ # noqa: F401, E402
13-
from ..v1.mapping import * # noqa: F403, F401, E402
14-
from ..v1.measurements import * # noqa: F403, F401, E402
15-
from ..v1.observables import * # noqa: F403, F401, E402
16-
from ..v1.parameter_mapping import * # noqa: F403, F401, E402
17-
from ..v1.parameters import * # noqa: F403, F401, E402
18-
from ..v1.sampling import * # noqa: F403, F401, E402
19-
from ..v1.sbml import * # noqa: F403, F401, E402
20-
from ..v1.simulate import * # noqa: F403, F401, E402
21-
from ..v1.yaml import * # noqa: F403, F401, E402
22-
238
warn(
249
"Support for PEtab2.0 and all of petab.v2 is experimental "
2510
"and subject to changes!",
2611
stacklevel=1,
2712
)
2813

14+
# TODO: move this module to v2
15+
from petab.v1.mapping import ( # noqa: F403, F401, E402
16+
get_mapping_df,
17+
write_mapping_df,
18+
)
19+
from petab.v1.measurements import ( # noqa: F401, E402
20+
get_measurement_df,
21+
write_measurement_df,
22+
)
23+
from petab.v1.observables import ( # noqa: F401, E402
24+
get_observable_df,
25+
write_observable_df,
26+
)
27+
from petab.v1.yaml import load_yaml # noqa: F401, E402
28+
2929
# import after v1
3030
from ..version import __version__ # noqa: F401, E402
3131
from . import ( # noqa: F401, E402
@@ -38,5 +38,5 @@
3838
write_experiment_df,
3939
)
4040
from .lint import lint_problem # noqa: F401, E402
41-
from .models import Model # noqa: F401, E402
42-
from .problem import Problem # noqa: F401, E402
41+
from .models import MODEL_TYPE_PYSB, MODEL_TYPE_SBML, Model # noqa: F401, E402
42+
from .problem import Problem, ProblemConfig # noqa: F401, E402

petab/v2/petab1to2.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Convert PEtab version 1 problems to version 2."""
22

3+
from __future__ import annotations
4+
35
import shutil
46
from contextlib import suppress
57
from itertools import chain
@@ -14,12 +16,13 @@
1416
from ..v1.yaml import get_path_prefix, load_yaml, validate
1517
from ..versions import get_major_version
1618
from .models import MODEL_TYPE_SBML
17-
from .problem import ProblemConfig
1819

1920
__all__ = ["petab1to2"]
2021

2122

22-
def petab1to2(yaml_config: Path | str, output_dir: Path | str = None):
23+
def petab1to2(
24+
yaml_config: Path | str, output_dir: Path | str = None
25+
) -> v2.Problem | None:
2326
"""Convert from PEtab 1.0 to PEtab 2.0 format.
2427
2528
Convert a PEtab problem from PEtab 1.0 to PEtab 2.0 format.
@@ -56,7 +59,7 @@ def petab1to2(yaml_config: Path | str, output_dir: Path | str = None):
5659

5760
get_dest_path = lambda filename: f"{output_dir}/{filename}" # noqa: E731
5861

59-
# Validate original PEtab problem
62+
# Validate the original PEtab problem
6063
validate(yaml_config, path_prefix=path_prefix)
6164
if get_major_version(yaml_config) != 1:
6265
raise ValueError("PEtab problem is not version 1.")
@@ -72,7 +75,7 @@ def petab1to2(yaml_config: Path | str, output_dir: Path | str = None):
7275

7376
# Update YAML file
7477
new_yaml_config = _update_yaml(yaml_config)
75-
new_yaml_config = ProblemConfig(**new_yaml_config)
78+
new_yaml_config = v2.ProblemConfig(**new_yaml_config)
7679

7780
# Update tables
7881
# condition tables, observable tables, SBML files, parameter table:
@@ -218,7 +221,7 @@ def create_experiment_id(sim_cond_id: str, preeq_cond_id: str) -> str:
218221
measurement_df, get_dest_path(measurement_file)
219222
)
220223

221-
# Write new YAML file
224+
# Write the new YAML file
222225
new_yaml_file = output_dir / Path(yaml_file).name
223226
new_yaml_config.to_yaml(new_yaml_file)
224227

0 commit comments

Comments
 (0)