Skip to content

Commit 1557be3

Browse files
committed
JNIE - More aggresive fix to convert_csv_to_yaml
1 parent 48af412 commit 1557be3

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

scripts/convert_product_definition_to_yaml.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def convert_csv_to_yaml(file_path):
3737
else:
3838
required_variables = required_for_data
3939

40-
if "RECORD_VARYING" in header_to_index and row[header_to_index["RECORD_VARYING"]].lower() == "nrv":
40+
if (("RECORD_VARYING" in required_variables or "RECORD_VARYING" in header_to_index)
41+
and row[header_to_index["RECORD_VARYING"]].lower() == "nrv"):
4142
required_variables = [variable for variable in required_variables if
4243
variable != "DEPEND_0"]
4344

tests/scripts/test_convert_product_definition_to_yaml.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def test_parse_required_for_data_with_multiple_depend(self):
2525
"FILLVAL": ["-1.00E+31", "", ""],
2626
"LABL_PTR_1": ["energy_label", "", ""],
2727
"LABL_PTR_2": ["pitch_angle_label", "", ""],
28-
"VARIABLE_PURPOSE": ["primary var, summary", "", ""]
28+
"VARIABLE_PURPOSE": ["primary var, summary", "", ""],
29+
"RECORD_VARYING": ["rv", "nrv", "nrv"]
2930
}
3031

3132
rows = [
@@ -58,6 +59,7 @@ def test_parse_required_for_data_with_multiple_depend(self):
5859
LABL_PTR_1: energy_label
5960
LABL_PTR_2: pitch_angle_label
6061
VARIABLE_PURPOSE: primary var, summary
62+
RECORD_VARYING: rv
6163
energy_label:
6264
NAME: energy_label
6365
DATA_TYPE: str
@@ -160,7 +162,8 @@ def test_parse_required_for_support_data_non_rv(self):
160162

161163
def test_parse_required_for_data_epoch(self):
162164
required_for_data = ["NAME", "DATA_TYPE", "CATDESC", "VAR_TYPE", "DEPEND_0", "DISPLAY_TYPE",
163-
"FIELDNAM", "FORMAT", "LABLAXIS", "UNITS", "VALIDMIN", "VALIDMAX", "FILLVAL"]
165+
"FIELDNAM", "FORMAT", "LABLAXIS", "UNITS", "VALIDMIN", "VALIDMAX", "FILLVAL",
166+
"RECORD_VARYING"]
164167

165168
test_csv_values = [
166169
"epoch",
@@ -175,7 +178,8 @@ def test_parse_required_for_data_epoch(self):
175178
"",
176179
"",
177180
"",
178-
"-1.00E+31"
181+
"-1.00E+31",
182+
"rv"
179183
]
180184
filePath = "csv_test_file.csv"
181185
with open(filePath, "w", newline='') as csvfile:
@@ -193,7 +197,8 @@ def test_parse_required_for_data_epoch(self):
193197
UNITS: ' '
194198
VALIDMIN: ' '
195199
VALIDMAX: ' '
196-
FILLVAL: -1.00E+31"""
200+
FILLVAL: -1.00E+31
201+
RECORD_VARYING: rv"""
197202
actual_yaml = convert_csv_to_yaml(filePath)
198203
self.assertEqual(expected_yaml, actual_yaml)
199204

0 commit comments

Comments
 (0)