Skip to content

Commit baa5932

Browse files
authored
I1423, fixing style name problem on RTFD builds (#1424)
* skyfield_data updated * default name for generic styles * use same name as in tests * section moved * next step raising on wrong class * ignore HS|VS_GenericStyle * log IndexError * propper name for the workflow * flake8 * name clarified * syntax fix
1 parent 56b0d9a commit baa5932

File tree

6 files changed

+51
-9
lines changed

6 files changed

+51
-9
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build Gallery
2+
3+
on: pull_request
4+
5+
jobs:
6+
Test-MSS-docs:
7+
runs-on: ubuntu-latest
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
container:
14+
image: openmss/mss-test:latest
15+
16+
steps:
17+
- name: Trust My Directory
18+
run: git config --global --add safe.directory /__w/MSS/MSS
19+
- uses: actions/checkout@v2
20+
21+
- name: Create gallery
22+
timeout-minutes: 25
23+
run: |
24+
source /opt/conda/bin/activate mssenv \
25+
&& cd $GITHUB_WORKSPACE/docs \
26+
&& python conf.py

docs/components.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Components
55
:maxdepth: 3
66

77
usage
8-
deployment
98
mswms
109
mscolab
1110
tutorials

docs/usage.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ aircraft performance. Such a file may be loaded using the 'performance settings'
164164
in Table View. The aircraft performance is specified using tables given in the JSON format.
165165
A basic configuration looks like the following file:
166166

167-
.. literalinclude:: samples/config/mss/performance_simple.json.sample
167+
.. literalinclude:: samples/config/mss/performance_simple.json
168168

169169
This example file assumes a constant speed of 400 nm/h and a constant fuel consumption of
170170
2900 lbs/h irrespective of flight level changes. The aircraft weight and available fuel are
@@ -315,4 +315,4 @@ for instance a number of the same plots or several flights or several forecast s
315315

316316
The retriever is an example which needs tweaked before using it
317317

318-
.. literalinclude:: samples/automation/retriever.py
318+
.. literalinclude:: samples/automation/retriever.py

mslib/mswms/mpl_hsec_styles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ class HS_GenericStyle(MPLBasemapHorizontalSectionStyle):
398398
"""
399399
Pressure level version for Chemical Mixing ratios.
400400
"""
401+
name = "HS_GenericStyle"
401402
styles = [
402403
("auto", "auto colour scale"),
403404
("autolog", "auto logcolour scale"), ]

mslib/mswms/mpl_vsec_styles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class VS_GenericStyle(AbstractVerticalSectionStyle):
114114
"""
115115
Vertical section of chemical species/other stuff
116116
"""
117+
name = "VS_GenericStyle"
117118
styles = [
118119
("auto", "auto colour scale"),
119120
("autolog", "auto log colour scale"), ]

mslib/mswms/wms.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,13 @@ def generate_gallery(self, create=False, clear=False, generate_code=False, sphin
232232
dataset = [next(iter(mss_wms_settings.data))]
233233
mss_wms_settings.register_horizontal_layers = [
234234
(plot[1], dataset) for plot in inspect.getmembers(mpl_hsec_styles, inspect.isclass)
235-
if not any(x in plot[0] or x in str(plot[1]) for x in ["Abstract", "Target", "fnord"])
235+
if plot[0] != "HS_GenericStyle" and
236+
not any(x in plot[0] or x in str(plot[1]) for x in ["Abstract", "Target", "fnord"])
236237
]
237238
mss_wms_settings.register_vertical_layers = [
238239
(plot[1], dataset) for plot in inspect.getmembers(mpl_vsec_styles, inspect.isclass)
239-
if not any(x in plot[0] or x in str(plot[1]) for x in ["Abstract", "Target", "fnord"])
240+
if plot[0] != "VS_GenericStyle" and
241+
not any(x in plot[0] or x in str(plot[1]) for x in ["Abstract", "Target", "fnord"])
240242
]
241243
mss_wms_settings.register_linear_layers = [
242244
(plot[1], dataset) for plot in inspect.getmembers(mpl_lsec_styles, inspect.isclass)
@@ -249,7 +251,7 @@ def generate_gallery(self, create=False, clear=False, generate_code=False, sphin
249251
tmp_path = tempfile.mkdtemp()
250252
path = DOCS_LOCATION if sphinx else STATIC_LOCATION
251253

252-
if not plot_list:
254+
if plot_list is None:
253255
plot_list = [[self.lsec_drivers, self.lsec_layer_registry],
254256
[self.vsec_drivers, self.vsec_layer_registry],
255257
[self.hsec_drivers, self.hsec_layer_registry]]
@@ -287,9 +289,16 @@ def generate_gallery(self, create=False, clear=False, generate_code=False, sphin
287289
elif not plot_driver.get_init_times():
288290
itime = None
289291

290-
# All valid times for the specific init time
291-
i_vtimes = plot_driver.get_valid_times(plot_object.required_datafields[0][1], file_type,
292-
itime)
292+
try:
293+
# All valid times for the specific init time
294+
i_vtimes = plot_driver.get_valid_times(plot_object.required_datafields[0][1],
295+
file_type, itime)
296+
except IndexError:
297+
# ToDo fix demodata for sfc
298+
logging.debug("plot_object.required_datafields incomplete"
299+
" for filetype: %s in dataset: %s for l_type: %s",
300+
file_type, dataset, l_type)
301+
continue
293302

294303
# All specified valid times, or the latest if empty, or all if "all",
295304
# or None if there are no valid times for the init time
@@ -455,6 +464,9 @@ def register_hsec_layer(self, datasets, layer_class):
455464
if layer.name in self.hsec_layer_registry[dataset]:
456465
raise ValueError(f"new layer is already registered? dataset={dataset} layer.name={layer.name} "
457466
f"new={layer} old={self.hsec_layer_registry[dataset][layer.name]}")
467+
if layer.name == "HS_GenericStyle":
468+
raise ValueError(f"problem in configuration for dataset={dataset}. We found layer.name={layer.name}"
469+
f" The class HS_GenericStyle should never be used.")
458470
self.hsec_layer_registry[dataset][layer.name] = layer
459471

460472
def register_vsec_layer(self, datasets, layer_class):
@@ -483,6 +495,9 @@ def register_vsec_layer(self, datasets, layer_class):
483495
if layer.name in self.vsec_layer_registry[dataset]:
484496
raise ValueError(f"new layer is already registered? dataset={dataset} layer.name={layer.name} "
485497
f"new={layer} old={self.vsec_layer_registry[dataset][layer.name]}")
498+
if layer.name == "VS_GenericStyle":
499+
raise ValueError(f"problem in configuration for dataset={dataset}. We found layer.name={layer.name}"
500+
f" The class VS_GenericStyle should never be used.")
486501
self.vsec_layer_registry[dataset][layer.name] = layer
487502

488503
def register_lsec_layer(self, datasets, variable=None, filetype="ml", layer_class=None):

0 commit comments

Comments
 (0)