Skip to content

Commit 6914b72

Browse files
committed
Move InstrumentType to ship_config.py
1 parent d910ff0 commit 6914b72

File tree

10 files changed

+25
-26
lines changed

10 files changed

+25
-26
lines changed

src/virtualship/cli/_fetch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _fetch(path: str | Path, username: str | None, password: str | None) -> None
3838
be provided on prompt, via command line arguments, or via a YAML config file. Run
3939
`virtualship fetch` on an expedition for more info.
4040
"""
41-
from virtualship.expedition.instrument_type import InstrumentType
41+
from virtualship.expedition.ship_config import InstrumentType
4242

4343
if sum([username is None, password is None]) == 1:
4444
raise ValueError("Both username and password must be provided when using CLI.")

src/virtualship/expedition/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from .do_expedition import do_expedition
44
from .input_data import InputData
5-
from .instrument_type import InstrumentType
65
from .schedule import Schedule
76
from .ship_config import (
87
ADCPConfig,

src/virtualship/expedition/checkpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import pydantic
88
import yaml
99

10-
from .instrument_type import InstrumentType
1110
from .schedule import Schedule
11+
from .ship_config import InstrumentType
1212

1313

1414
class _YamlDumper(yaml.SafeDumper):

src/virtualship/expedition/instrument_type.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/virtualship/expedition/schedule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from parcels import FieldSet
1313

1414
from .input_data import InputData
15-
from .instrument_type import InstrumentType
15+
from .ship_config import InstrumentType
1616
from .space_time_region import SpaceTimeRegion
1717
from .waypoint import Waypoint
1818

src/virtualship/expedition/ship_config.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,26 @@
33
from __future__ import annotations
44

55
from datetime import timedelta
6+
from enum import Enum
67
from pathlib import Path
8+
from typing import TYPE_CHECKING
79

810
import pydantic
911
import yaml
1012

1113
from virtualship.utils import _validate_numeric_mins_to_timedelta
1214

13-
from .instrument_type import InstrumentType
14-
from .schedule import Schedule
15+
if TYPE_CHECKING:
16+
from .schedule import Schedule
17+
18+
19+
class InstrumentType(Enum):
20+
"""Types of instruments."""
21+
22+
CTD = "CTD"
23+
DRIFTER = "DRIFTER"
24+
ARGO_FLOAT = "ARGO_FLOAT"
25+
XBT = "XBT"
1526

1627

1728
class ArgoFloatConfig(pydantic.BaseModel):

src/virtualship/expedition/simulate_schedule.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
from ..instruments.xbt import XBT
1414
from ..location import Location
1515
from ..spacetime import Spacetime
16-
from .instrument_type import InstrumentType
1716
from .schedule import Schedule
18-
from .ship_config import ShipConfig
17+
from .ship_config import InstrumentType, ShipConfig
1918
from .waypoint import Waypoint
2019

2120

src/virtualship/expedition/waypoint.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
"""Waypoint class."""
22

3+
from __future__ import annotations
4+
35
from datetime import datetime
46

5-
from pydantic import BaseModel, field_serializer
7+
import pydantic
68

79
from ..location import Location
8-
from .instrument_type import InstrumentType
10+
from .ship_config import InstrumentType
911

1012

11-
class Waypoint(BaseModel):
13+
class Waypoint(pydantic.BaseModel):
1214
"""A Waypoint to sail to with an optional time and an optional instrument."""
1315

1416
location: Location
1517
time: datetime | None = None
1618
instrument: InstrumentType | list[InstrumentType] | None = None
1719

18-
@field_serializer("instrument")
20+
@pydantic.field_serializer("instrument")
1921
def serialize_instrument(self, instrument):
2022
"""Ensure InstrumentType is serialized as a string (or list of strings)."""
2123
if isinstance(instrument, list):

src/virtualship/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def mfp_to_yaml(coordinates_file_path: str, yaml_output_path: str): # noqa: D41
139139
140140
"""
141141
# Importing Schedule and related models from expedition module
142-
from virtualship.expedition.instrument_type import InstrumentType
143142
from virtualship.expedition.schedule import Schedule
143+
from virtualship.expedition.ship_config import InstrumentType
144144
from virtualship.expedition.space_time_region import (
145145
SpaceTimeRegion,
146146
SpatialRange,

tests/test_mfp_to_yaml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import pandas as pd
44
import pytest
55

6-
from virtualship.expedition.instrument_type import InstrumentType
76
from virtualship.expedition.schedule import Schedule
7+
from virtualship.expedition.ship_config import InstrumentType
88
from virtualship.utils import mfp_to_yaml
99

1010

0 commit comments

Comments
 (0)