Skip to content

Commit 9b01b57

Browse files
committed
remove all deprecated science version formats vxxx
1 parent d15b6b4 commit 9b01b57

3 files changed

Lines changed: 15 additions & 46 deletions

File tree

imap_data_access/io.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def download(file_path: Union[Path, str]) -> Path:
125125

126126

127127
# Too many branches (16 >12)
128-
# ruff: noqa: PLR0912, PLR0915
128+
# ruff: noqa: PLR0912
129129
def _validate_query_parameters(**kwargs) -> None:
130130
"""Validate all parameters used in the query function.
131131
@@ -201,14 +201,6 @@ def _validate_query_parameters(**kwargs) -> None:
201201
" where <num> is a 5 digit integer."
202202
) from err
203203

204-
# Check version make sure to include 'latest'
205-
if table == "science":
206-
if version is not None and not file_validation.ScienceFilePath.is_valid_version(
207-
version
208-
):
209-
raise ValueError(
210-
"Not a valid version, use format 'vMMM.mmmm' or 'vXXX' (deprecated)."
211-
)
212204
elif version is not None and not file_validation.ImapFilePath.is_valid_version(
213205
version
214206
):

tests/test_file_validation.py

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def test_extract_filename_components():
2828
"data_level": "l1a",
2929
"descriptor": "burst",
3030
"start_date": "20210101",
31-
"version": "v001.0001",
3231
"major_version": 1,
3332
"minor_version": 1,
3433
"repointing": None,
@@ -68,29 +67,6 @@ def test_extract_filename_components():
6867
)
6968

7069

71-
# TODO remove this test after file versions are updated from vXXX to vRRR.MMM
72-
def test_extract_filename_components_deprecated_version_format():
73-
"""Tests the ``extract_filename_components` with old filename convention."""
74-
valid_filename = "imap_mag_l1a_burst_20210101_v001.pkts"
75-
# Use deprecated version format
76-
expected_output = {
77-
"mission": "imap",
78-
"instrument": "mag",
79-
"data_level": "l1a",
80-
"descriptor": "burst",
81-
"start_date": "20210101",
82-
"major_version": None,
83-
"minor_version": 1,
84-
"repointing": None,
85-
"cr": None,
86-
"version": "v001",
87-
"extension": "pkts",
88-
}
89-
assert (
90-
ScienceFilePath.extract_filename_components(valid_filename) == expected_output
91-
)
92-
93-
9470
def test_construct_sciencefilepathmanager():
9571
"""Tests that the ``ScienceFilePath`` class constructs a valid filename."""
9672
valid_filename = "imap_mag_l1a_burst_20210101_v001.0001.cdf"
@@ -101,41 +77,41 @@ def test_construct_sciencefilepathmanager():
10177
assert sfm.descriptor == "burst"
10278
assert sfm.start_date == "20210101"
10379
assert sfm.repointing is None
104-
assert sfm.version == "v001.0001"
10580
assert sfm.major_version == 1
10681
assert sfm.minor_version == 1
10782
assert sfm.extension == "cdf"
10883

10984
# no extension
110-
invalid_filename = "imap_mag_l1a_burst_20210101_v001"
85+
invalid_filename = "imap_mag_l1a_burst_20210101_v001.0001"
11186
with pytest.raises(ScienceFilePath.InvalidImapFileError):
11287
ScienceFilePath(invalid_filename)
11388

11489
# invalid extension
115-
invalid_filename = "imap_mag_l1a_burst_20210101_v001.abc"
90+
invalid_filename = "imap_mag_l1a_burst_20210101_v001.0001.abc"
11691
with pytest.raises(ScienceFilePath.InvalidImapFileError):
11792
ScienceFilePath(invalid_filename)
11893

11994
# invalid instrument
120-
invalid_filename = "imap_sdc_l1a_burst_20210101_v001.cdf"
95+
invalid_filename = "imap_sdc_l1a_burst_20210101_v001.0001.cdf"
12196
with pytest.raises(ScienceFilePath.InvalidImapFileError):
12297
ScienceFilePath(invalid_filename)
12398

12499
# Bad repointing, not 5 digits
125-
invalid_filename = "imap_mag_l1a_burst_20210101-repoint0001_v001.cdf"
100+
invalid_filename = "imap_mag_l1a_burst_20210101-repoint0001_v001.0001.cdf"
126101
with pytest.raises(ScienceFilePath.InvalidImapFileError):
127102
ScienceFilePath(invalid_filename)
128103

129104
# good path with an extra "test" directory
130-
valid_filepath = Path("/test/imap_mag_l1a_burst_20210101_v001.cdf")
105+
valid_filepath = Path("/test/imap_mag_l1a_burst_20210101_v001.0001.cdf")
131106
sfm = ScienceFilePath(valid_filepath)
132107

133108
assert sfm.instrument == "mag"
134109
assert sfm.data_level == "l1a"
135110
assert sfm.descriptor == "burst"
136111
assert sfm.start_date == "20210101"
137112
assert sfm.repointing is None
138-
assert sfm.version == "v001"
113+
assert sfm.major_version == 1
114+
assert sfm.minor_version == 1
139115
assert sfm.extension == "cdf"
140116

141117
# Test valid date for given start_date
@@ -160,10 +136,10 @@ def test_is_valid_date():
160136

161137
def test_construct_upload_path():
162138
"""Tests the ``construct_path`` method."""
163-
valid_filename = "imap_mag_l1a_burst_20210101_v001.cdf"
139+
valid_filename = "imap_mag_l1a_burst_20210101_v001.0001.cdf"
164140
sfm = ScienceFilePath(valid_filename)
165141
expected_output = imap_data_access.config["DATA_DIR"] / Path(
166-
"imap/mag/l1a/2021/01/imap_mag_l1a_burst_20210101_v001.cdf"
142+
"imap/mag/l1a/2021/01/imap_mag_l1a_burst_20210101_v001.0001.cdf"
167143
)
168144

169145
assert sfm.construct_path() == expected_output
@@ -182,7 +158,8 @@ def test_generate_from_inputs():
182158
assert sfm.descriptor == "burst"
183159
assert sfm.start_date == "20210101"
184160
assert sfm.repointing is None
185-
assert sfm.version == "v000.0001"
161+
assert sfm.major_version == 0
162+
assert sfm.minor_version == 1
186163
assert sfm.extension == "cdf"
187164

188165
sfm = ScienceFilePath.generate_from_inputs("mag", "l0", "raw", "20210101", 0, 1)
@@ -664,7 +641,7 @@ def test_quicklook_file_path():
664641
assert file_all_params.construct_path() == expected_output
665642

666643
# Test by passing the file
667-
file = QuicklookFilePath("imap_mag_l1a_test_20210101_v001.png")
644+
file = QuicklookFilePath("imap_mag_l1a_test_20210101_v001.0001.png")
668645
assert file.instrument == "mag"
669646
assert file.start_date == "20210101"
670647

@@ -726,7 +703,7 @@ def test_dependency_file_path():
726703
assert file_all_params.construct_path() == expected_output
727704

728705
# Test by passing the file
729-
file = DependencyFilePath("imap_mag_l1a_test_20210101_v001.json")
706+
file = DependencyFilePath("imap_mag_l1a_test_20210101_v000.0001.json")
730707
assert file.instrument == "mag"
731708
assert file.start_date == "20210101"
732709

tests/test_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ def test_spice_query_bad_params(mock_send_request):
638638
"Not a valid repointing, use format repoint<num>, "
639639
"where <num> is a 5 digit integer.",
640640
),
641-
("version", "badInput", "Not a valid version, use format 'vMMM.mmmm."),
641+
("version", "badInput", "Not a valid version, use format 'vXXX"),
642642
(
643643
"extension",
644644
"badInput",

0 commit comments

Comments
 (0)