diff --git a/jwql/database/database_interface.py b/jwql/database/database_interface.py index 73b536eed..d94532ef4 100644 --- a/jwql/database/database_interface.py +++ b/jwql/database/database_interface.py @@ -84,10 +84,9 @@ from jwql.utils.constants import ANOMALIES_PER_INSTRUMENT from jwql.utils.constants import FILE_SUFFIX_TYPES from jwql.utils.constants import JWST_INSTRUMENT_NAMES +from jwql.utils.constants import ON_GITHUB_ACTIONS from jwql.utils.utils import get_config -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - # Monkey patch Query with data_frame method @property diff --git a/jwql/edb/engineering_database.py b/jwql/edb/engineering_database.py index fea43aafa..b342b2743 100644 --- a/jwql/edb/engineering_database.py +++ b/jwql/edb/engineering_database.py @@ -58,20 +58,20 @@ from astroquery.mast import Mast from bokeh.embed import components from bokeh.layouts import column -from bokeh.models import BoxAnnotation, ColumnDataSource, DatetimeTickFormatter, HoverTool, Range1d +from bokeh.models import BoxAnnotation, ColumnDataSource, DatetimeTickFormatter, HoverTool +from bokeh.models import Range1d from bokeh.plotting import figure, output_file, show, save import numpy as np from jwst.lib.engdb_tools import ENGDB_Service from jwql.utils.constants import MIRI_POS_RATIO_VALUES +from jwql.utils.constants import ON_GITHUB_ACTIONS from jwql.utils.credentials import get_mast_base_url, get_mast_token from jwql.utils.utils import get_config MAST_EDB_MNEMONIC_SERVICE = 'Mast.JwstEdb.Mnemonics' MAST_EDB_DICTIONARY_SERVICE = 'Mast.JwstEdb.Dictionary' -# Temporary until JWST operations: switch to test string for MAST request URL -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') if not ON_GITHUB_ACTIONS: Mast._portal_api_connection.MAST_REQUEST_URL = get_config()['mast_request_url'] @@ -283,7 +283,7 @@ def __mul__(self, mnem): before = np.where(common_dates == self.data['dates'][block])[0] if len(before) > 0: - new_blocks.append(before[0]) # + 1) + new_blocks.append(before[0]) # + 1) except IndexError: # The final block value is usually equal to the length of the array, and will # therefore cause an Index Error in the lines above. Ignore that error here. @@ -421,7 +421,7 @@ def block_stats(self, sigma=3, ignore_vals=[], ignore_edges=False, every_change= # calculated, remove those every change values and block values from the EdbMnemonic # instance. if every_change: - if len(remove_change_indexes) > 0: + if len(remove_change_indexes) > 0: self.every_change_values = np.delete(self.every_change_values, remove_change_indexes) self.blocks = np.delete(self.blocks, remove_change_indexes) @@ -439,7 +439,7 @@ def block_stats(self, sigma=3, ignore_vals=[], ignore_edges=False, every_change= stdevs.append(stdevval) maxs.append(meanval) mins.append(meanval) - #if hasattr(self, 'every_change_values'): + # if hasattr(self, 'every_change_values'): # updated_every_change_vals.append(self.every_change_values[i + 1]) self.mean = means self.median = medians @@ -510,9 +510,9 @@ def block_stats_filter_positions(self, sigma=5): self.data["euvalues"].data[index:self.blocks[i + 1]], sigma=sigma) if np.isfinite(meanval): - #this is preventing the nans above from being added. not sure what to do here. - #bokeh cannot deal with nans. but we need entries in order to have the blocks indexes - #remain correct. but maybe we dont care about the block indexes after averaging + # this is preventing the nans above from being added. not sure what to do here. + # bokeh cannot deal with nans. but we need entries in order to have the blocks indexes + # remain correct. but maybe we dont care about the block indexes after averaging medtimes.append(calc_median_time(self.data["dates"].data[index:self.blocks[i + 1]][good])) means.append(meanval) medians.append(medianval) @@ -523,7 +523,7 @@ def block_stats_filter_positions(self, sigma=5): # If there were blocks composed entirely of bad data, meaning no mean values were # calculated, remove those every change values and block values from the EdbMnemonic # instance. - if len(remove_change_indexes) > 0: + if len(remove_change_indexes) > 0: self.every_change_values = np.delete(self.every_change_values, remove_change_indexes) self.blocks = np.delete(self.blocks, remove_change_indexes) @@ -690,37 +690,33 @@ def bokeh_plot(self, show_plot=False, savefig=False, out_dir='./', nominal_value if plot_mean: source_mean = ColumnDataSource(data={'mean_x': self.median_times, 'mean_y': self.mean}) mean_data = fig.scatter(x='mean_x', y='mean_y', line_width=1, line_color='orange', alpha=0.75, source=source_mean) - mean_hover_tool = HoverTool(tooltips=[('Mean', '@mean_y'), - ('Date', '@mean_x{%d %b %Y %H:%M:%S}') - ], mode='mouse', renderers=[mean_data]) + mean_hover_tool = HoverTool(tooltips=[('Mean', '@mean_y'), ('Date', '@mean_x{%d %b %Y %H:%M:%S}')], + mode='mouse', renderers=[mean_data]) mean_hover_tool.formatters = {'@mean_x': 'datetime'} fig.tools.append(mean_hover_tool) if plot_median: source_median = ColumnDataSource(data={'median_x': self.median_times, 'median_y': self.median}) median_data = fig.scatter(x='median_x', y='median_y', line_width=1, line_color='orangered', alpha=0.75, source=source_median) - median_hover_tool = HoverTool(tooltips=[('Median', '@median_y'), - ('Date', '@median_x{%d %b %Y %H:%M:%S}') - ], mode='mouse', renderers=[median_data]) + median_hover_tool = HoverTool(tooltips=[('Median', '@median_y'), ('Date', '@median_x{%d %b %Y %H:%M:%S}')], + mode='mouse', renderers=[median_data]) median_hover_tool.formatters = {'@median_x': 'datetime'} fig.tools.append(median_hover_tool) - # If the max and min arrays are to be plotted, create columndata sources for them as well + # If the max and min arrays are to be plotted, create columndata sources for them as well if plot_max: source_max = ColumnDataSource(data={'max_x': self.median_times, 'max_y': self.max}) max_data = fig.scatter(x='max_x', y='max_y', line_width=1, color='black', line_color='black', source=source_max) - max_hover_tool = HoverTool(tooltips=[('Max', '@max_y'), - ('Date', '@max_x{%d %b %Y %H:%M:%S}') - ], mode='mouse', renderers=[max_data]) + max_hover_tool = HoverTool(tooltips=[('Max', '@max_y'), ('Date', '@max_x{%d %b %Y %H:%M:%S}')], + mode='mouse', renderers=[max_data]) max_hover_tool.formatters = {'@max_x': 'datetime'} fig.tools.append(max_hover_tool) if plot_min: source_min = ColumnDataSource(data={'min_x': self.median_times, 'min_y': self.min}) min_data = fig.scatter(x='min_x', y='min_y', line_width=1, color='black', line_color='black', source=source_min) - minn_hover_tool = HoverTool(tooltips=[('Min', '@min_y'), - ('Date', '@min_x{%d %b %Y %H:%M:%S}') - ], mode='mouse', renderers=[min_data]) + minn_hover_tool = HoverTool(tooltips=[('Min', '@min_y'), ('Date', '@min_x{%d %b %Y %H:%M:%S}')], + mode='mouse', renderers=[min_data]) min_hover_tool.formatters = {'@min_x': 'datetime'} fig.tools.append(min_hover_tool) diff --git a/jwql/instrument_monitors/common_monitors/bad_pixel_monitor.py b/jwql/instrument_monitors/common_monitors/bad_pixel_monitor.py index c0366df14..d3ae2e795 100755 --- a/jwql/instrument_monitors/common_monitors/bad_pixel_monitor.py +++ b/jwql/instrument_monitors/common_monitors/bad_pixel_monitor.py @@ -105,19 +105,13 @@ from jwql.shared_tasks.shared_tasks import only_one, run_pipeline, run_parallel_pipeline from jwql.utils import crds_tools, instrument_properties, monitor_utils from jwql.utils.constants import DARKS_BAD_PIXEL_TYPES, DARK_EXP_TYPES, FLATS_BAD_PIXEL_TYPES, FLAT_EXP_TYPES -from jwql.utils.constants import JWST_INSTRUMENT_NAMES, JWST_INSTRUMENT_NAMES_MIXEDCASE +from jwql.utils.constants import JWST_INSTRUMENT_NAMES, JWST_INSTRUMENT_NAMES_MIXEDCASE, ON_GITHUB_ACTIONS +from jwql.utils.constants import ON_READTHEDOCS from jwql.utils.logging_functions import log_info, log_fail from jwql.utils.mast_utils import mast_query from jwql.utils.permissions import set_permissions from jwql.utils.utils import copy_files, create_png_from_fits, ensure_dir_exists, get_config, filesystem_path -# Determine if the code is being run by Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - -# Determine if the code is being run as part of a Readthedocs build -ON_READTHEDOCS = False -if 'READTHEDOCS' in os.environ: # pragma: no cover - ON_READTHEDOCS = os.environ['READTHEDOCS'] if not ON_GITHUB_ACTIONS and not ON_READTHEDOCS: from jwql.website.apps.jwql.monitor_pages.monitor_bad_pixel_bokeh import BadPixelPlots diff --git a/jwql/instrument_monitors/common_monitors/readnoise_monitor.py b/jwql/instrument_monitors/common_monitors/readnoise_monitor.py index 9401ce3b4..36543cc6e 100755 --- a/jwql/instrument_monitors/common_monitors/readnoise_monitor.py +++ b/jwql/instrument_monitors/common_monitors/readnoise_monitor.py @@ -44,18 +44,19 @@ import crds import matplotlib matplotlib.use('Agg') -import matplotlib.pyplot as plt # noqa: E348 (comparison to true) -import numpy as np # noqa: E348 (comparison to true) -from pysiaf import Siaf # noqa: E348 (comparison to true) - -# astroquery.mast import that depends on value of auth_mast -# this import has to be made before any other import of astroquery.mast -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - -# Determine if the code is being run as part of a Readthedocs build -ON_READTHEDOCS = False -if 'READTHEDOCS' in os.environ: # pragma: no cover - ON_READTHEDOCS = os.environ['READTHEDOCS'] +import matplotlib.pyplot as plt # noqa: E402 (module level import not at top of file) +import numpy as np # noqa: E402 (module level import not at top of file) +from pysiaf import Siaf # noqa: E402 (module level import not at top of file) + +from jwql.shared_tasks.shared_tasks import only_one, run_pipeline, run_parallel_pipeline # noqa: E402 (module level import not at top of file) +from jwql.instrument_monitors import pipeline_tools # noqa: E402 (module level import not at top of file) +from jwql.utils import instrument_properties, monitor_utils # noqa: E402 (module level import not at top of file) +from jwql.utils.constants import JWST_INSTRUMENT_NAMES, JWST_INSTRUMENT_NAMES_MIXEDCASE # noqa: E402 (module level import not at top of file) +from jwql.utils.constants import ON_GITHUB_ACTIONS, ON_READTHEDOCS # noqa: E402 (module level import not at top of file) +from jwql.utils.logging_functions import log_info, log_fail # noqa: E402 (module level import not at top of file) +from jwql.utils.monitor_utils import update_monitor_table # noqa: E402 (module level import not at top of file) +from jwql.utils.permissions import set_permissions # noqa: E402 (module level import not at top of file) +from jwql.utils.utils import ensure_dir_exists, filesystem_path, get_config, copy_files # noqa: E402 (module level import not at top of file) if not ON_GITHUB_ACTIONS and not ON_READTHEDOCS: # Need to set up django apps before we can access the models @@ -67,15 +68,6 @@ # for this monitor from jwql.website.apps.jwql.monitor_models.readnoise import * # noqa: E402 (module level import not at top of file) -from jwql.shared_tasks.shared_tasks import only_one, run_pipeline, run_parallel_pipeline # noqa: E348 (comparison to true) -from jwql.instrument_monitors import pipeline_tools # noqa: E348 (comparison to true) -from jwql.utils import instrument_properties, monitor_utils # noqa: E348 (comparison to true) -from jwql.utils.constants import JWST_INSTRUMENT_NAMES, JWST_INSTRUMENT_NAMES_MIXEDCASE # noqa: E348 (comparison to true) -from jwql.utils.logging_functions import log_info, log_fail # noqa: E348 (comparison to true) -from jwql.utils.monitor_utils import update_monitor_table # noqa: E348 (comparison to true) -from jwql.utils.permissions import set_permissions # noqa: E348 (comparison to true) -from jwql.utils.utils import ensure_dir_exists, filesystem_path, get_config, copy_files # noqa: E348 (comparison to true) - class Readnoise(): """Class for executing the readnoise monitor. diff --git a/jwql/tests/test_api_views.py b/jwql/tests/test_api_views.py index e3a2d1ca1..7b0994536 100644 --- a/jwql/tests/test_api_views.py +++ b/jwql/tests/test_api_views.py @@ -29,9 +29,8 @@ from jwql.utils.utils import get_base_url from jwql.utils.constants import JWST_INSTRUMENT_NAMES +from jwql.utils.constants import ON_GITHUB_ACTIONS -# Determine if tests are being run on Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') urls = [] diff --git a/jwql/tests/test_bad_pixel_monitor.py b/jwql/tests/test_bad_pixel_monitor.py index 4bc5c9d92..b3cae5fc3 100644 --- a/jwql/tests/test_bad_pixel_monitor.py +++ b/jwql/tests/test_bad_pixel_monitor.py @@ -32,9 +32,7 @@ from jwql.database.database_interface import FGSBadPixelQueryHistory, FGSBadPixelStats from jwql.instrument_monitors.common_monitors import bad_pixel_monitor from jwql.tests.resources import has_test_db - -# Determine if tests are being run on Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') +from jwql.utils.constants import ON_GITHUB_ACTIONS def test_bad_map_to_list(): diff --git a/jwql/tests/test_bias_monitor.py b/jwql/tests/test_bias_monitor.py index 6e73a0c01..e5335ea34 100644 --- a/jwql/tests/test_bias_monitor.py +++ b/jwql/tests/test_bias_monitor.py @@ -28,8 +28,7 @@ from jwql.instrument_monitors.common_monitors import bias_monitor from jwql.tests.resources import has_test_db from jwql.utils.utils import get_config - -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') +from jwql.utils.constants import ON_GITHUB_ACTIONS def test_collapse_image(): diff --git a/jwql/tests/test_cosmic_ray_monitor.py b/jwql/tests/test_cosmic_ray_monitor.py index c9d590a3b..dfe27e4e2 100644 --- a/jwql/tests/test_cosmic_ray_monitor.py +++ b/jwql/tests/test_cosmic_ray_monitor.py @@ -26,8 +26,7 @@ from jwql.instrument_monitors.common_monitors.cosmic_ray_monitor import CosmicRay from jwql.database.database_interface import MIRICosmicRayQueryHistory from jwql.utils.utils import get_config - -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') +from jwql.utils.constants import ON_GITHUB_ACTIONS def define_test_data(nints): diff --git a/jwql/tests/test_dark_monitor.py b/jwql/tests/test_dark_monitor.py index 9cb11a96f..a9fe14547 100644 --- a/jwql/tests/test_dark_monitor.py +++ b/jwql/tests/test_dark_monitor.py @@ -29,8 +29,7 @@ from jwql.tests.resources import has_test_db from jwql.utils.monitor_utils import mast_query_darks from jwql.utils.utils import get_config - -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') +from jwql.utils.constants import ON_GITHUB_ACTIONS def test_find_hot_dead_pixels(): diff --git a/jwql/tests/test_data_containers.py b/jwql/tests/test_data_containers.py index 6cb278c5e..2f799068b 100644 --- a/jwql/tests/test_data_containers.py +++ b/jwql/tests/test_data_containers.py @@ -31,18 +31,18 @@ import pandas as pd import pytest +from jwql.utils.constants import ON_GITHUB_ACTIONS + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "jwql.website.jwql_proj.settings") # Skip testing this module if on Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') -from jwql.website.apps.jwql import data_containers -from jwql.tests.resources import ( - MockSessionFileAnomaly, MockSessionGroupAnomaly, - MockGetRequest, MockPostRequest) -from jwql.utils import constants +from jwql.website.apps.jwql import data_containers # noqa: E402 (module level import not at top of file) +from jwql.tests.resources import MockSessionFileAnomaly, MockSessionGroupAnomaly # noqa: E402 (module level import not at top of file) +from jwql.tests.resources import MockGetRequest, MockPostRequest # noqa: E402 (module level import not at top of file) +from jwql.utils import constants # noqa: E402 (module level import not at top of file) if not ON_GITHUB_ACTIONS: - from jwql.utils.utils import get_config + from jwql.utils.utils import get_config # noqa: E402 (module level import not at top of file) @pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Requires access to django models.') @@ -142,17 +142,10 @@ def test_get_all_proposals(): (['uncal', 'rate', 'bad'], {'bad'})), (False, ['rate', 'uncal', 'bad'], ['uncal', 'rate', 'bad']), - (True, - ['rate', 'uncal', 'bad', - 'o006_crfints', 'o001_crf'], - (['uncal', 'rate', 'o001_crf', - 'o006_crfints', 'bad'], {'bad'})), - (False, - ['rate', 'uncal', 'bad', - 'o006_crfints', 'o001_crf'], - ['uncal', 'rate', 'o001_crf', - 'o006_crfints', 'bad']), - ]) + (True, ['rate', 'uncal', 'bad', 'o006_crfints', 'o001_crf'], + (['uncal', 'rate', 'o001_crf', 'o006_crfints', 'bad'], {'bad'})), + (False, ['rate', 'uncal', 'bad', 'o006_crfints', 'o001_crf'], + ['uncal', 'rate', 'o001_crf', 'o006_crfints', 'bad'])]) def test_get_available_suffixes(untracked, input_suffixes, expected): result = data_containers.get_available_suffixes( input_suffixes, return_untracked=untracked) @@ -292,6 +285,7 @@ def test_get_anomaly_form_post_group(mocker): assert update_mock.call_count == 2 """ + def test_get_dashboard_components(): request = MockPostRequest() diff --git a/jwql/tests/test_database_interface.py b/jwql/tests/test_database_interface.py index 08890a4f1..9719d9ab4 100755 --- a/jwql/tests/test_database_interface.py +++ b/jwql/tests/test_database_interface.py @@ -29,9 +29,7 @@ from jwql.database import database_interface as di from jwql.tests.resources import has_test_db from jwql.utils.utils import get_config - -# Determine if tests are being run on Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') +from jwql.utils.constants import ON_GITHUB_ACTIONS @pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Requires access to development database server.') diff --git a/jwql/tests/test_edb.py b/jwql/tests/test_edb.py index a7da24be5..bdbb4b179 100644 --- a/jwql/tests/test_edb.py +++ b/jwql/tests/test_edb.py @@ -28,9 +28,7 @@ import pytest from jwql.edb import engineering_database as ed - -# Determine if tests are being run on Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') +from jwql.utils.constants import ON_GITHUB_ACTIONS def test_add(): @@ -243,8 +241,8 @@ def test_multiplication(): info['description'] = 'Voltage at some place' mnemonic1 = ed.EdbMnemonic('TEST_VOLTAGE', Time('2021-12-18T07:20:00'), Time('2021-12-18T07:30:00'), tab, {}, info, blocks=blocks1) mnemonic1.meta = {'Count': 1, - 'TlmMnemonics': [{'TlmMnemonic': 'TEST_VOLTAGE', - 'AllPoints': 1}]} + 'TlmMnemonics': [{'TlmMnemonic': 'TEST_VOLTAGE', + 'AllPoints': 1}]} dates2 = np.array([datetime(2021, 12, 18, 7, n, 10) for n in range(20, 30)]) data2 = np.array([15, 15, 15, 19, 19, 19, 19, 19, 12, 12]) @@ -258,8 +256,8 @@ def test_multiplication(): info['description'] = 'Current at some place' mnemonic2 = ed.EdbMnemonic('TEST_CURRENT', Time('2021-12-18T07:20:10'), Time('2021-12-18T07:30:10'), tab, {}, info, blocks=blocks2) mnemonic2.meta = {'Count': 1, - 'TlmMnemonics': [{'TlmMnemonic': 'TEST_CURRENT', - 'AllPoints': 1}]} + 'TlmMnemonics': [{'TlmMnemonic': 'TEST_CURRENT', + 'AllPoints': 1}]} prod = mnemonic1 * mnemonic2 assert np.allclose(prod.data["euvalues"].data, diff --git a/jwql/tests/test_edb_telemetry_monitor.py b/jwql/tests/test_edb_telemetry_monitor.py index f7a91e5d3..8ddd21f6e 100644 --- a/jwql/tests/test_edb_telemetry_monitor.py +++ b/jwql/tests/test_edb_telemetry_monitor.py @@ -38,9 +38,6 @@ from jwql.tests.resources import has_test_db from jwql.utils.constants import MIRI_POS_RATIO_VALUES -# Determine if tests are being run on Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - def test_add_every_change_history(): """Test that every_change data is correctly combined with an existing @@ -107,13 +104,13 @@ def test_conditions(): """Test the extraction of data using the ```equal``` class. """ # Create data for mnemonic of interest - #start_time = Time('2022-02-02') - #end_time = Time('2022-02-03') + # start_time = Time('2022-02-02') + # end_time = Time('2022-02-03') start_time = datetime.datetime(2022, 2, 2) end_time = datetime.datetime(2022, 2, 3) temp_data = Table() temp_data["euvalues"] = np.array([35., 35.1, 35.2, 36., 36.1, 36.2, 37.1, 37., 36., 36.]) - #temp_data["dates"] = np.array([Time('2022-02-02') + TimeDelta(0.1 * i, format='jd') for i in range(10)]) + # temp_data["dates"] = np.array([Time('2022-02-02') + TimeDelta(0.1 * i, format='jd') for i in range(10)]) temp_data["dates"] = np.array([start_time + datetime.timedelta(days=0.1 * i) for i in range(10)]) meta = {} info = {} @@ -267,7 +264,7 @@ def test_organize_every_change(): """ basetime = datetime.datetime(2021, 4, 6, 14, 0, 0) dates = np.array([basetime + datetime.timedelta(seconds=600 * i) for i in range(20)]) - #dates = np.array([basetime + TimeDelta(600 * i, format='sec') for i in range(20)]) + # dates = np.array([basetime + TimeDelta(600 * i, format='sec') for i in range(20)]) vals = np.array([300.5, 310.3, -250.5, -500.9, 32.2, 300.1, 310.8, -250.2, -500.2, 32.7, 300.2, 310.4, -250.6, -500.8, 32.3, diff --git a/jwql/tests/test_instrument_properties.py b/jwql/tests/test_instrument_properties.py index 4176cd69c..4a072c7d1 100644 --- a/jwql/tests/test_instrument_properties.py +++ b/jwql/tests/test_instrument_properties.py @@ -23,8 +23,7 @@ import numpy as np from jwql.utils import instrument_properties - -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') +from jwql.utils.constants import ON_GITHUB_ACTIONS if not ON_GITHUB_ACTIONS: from jwql.utils.utils import get_config diff --git a/jwql/tests/test_loading_times.py b/jwql/tests/test_loading_times.py index 7c83fed72..02fa6ac24 100644 --- a/jwql/tests/test_loading_times.py +++ b/jwql/tests/test_loading_times.py @@ -25,13 +25,11 @@ import urllib.request from jwql.utils.constants import MONITORS +from jwql.utils.constants import ON_GITHUB_ACTIONS from jwql.utils.utils import get_base_url TIME_CONSTRAINT = 30 # seconds -# Determine if tests are being run on Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - urls = [] # Generic URLs diff --git a/jwql/tests/test_logging_functions.py b/jwql/tests/test_logging_functions.py index e68a65ee8..53913a0d0 100644 --- a/jwql/tests/test_logging_functions.py +++ b/jwql/tests/test_logging_functions.py @@ -25,11 +25,9 @@ from jwql.utils import logging_functions from jwql.utils.logging_functions import configure_logging, log_fail, log_info, make_log_file +from jwql.utils.constants import ON_GITHUB_ACTIONS from jwql.utils.utils import get_config -# Determine if tests are being run on Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - @log_fail @log_info diff --git a/jwql/tests/test_mast_utils.py b/jwql/tests/test_mast_utils.py index 74c3f0328..d32c2c9b2 100755 --- a/jwql/tests/test_mast_utils.py +++ b/jwql/tests/test_mast_utils.py @@ -22,11 +22,10 @@ from astroquery.mast import Mast from jwql.utils.constants import JWST_INSTRUMENT_NAMES +from jwql.utils.constants import ON_GITHUB_ACTIONS from jwql.utils import mast_utils as mu from jwql.utils.utils import get_config -# Temporary until JWST operations: switch to test string for MAST request URL -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') if not ON_GITHUB_ACTIONS: Mast._portal_api_connection.MAST_REQUEST_URL = get_config()['mast_request_url'] @@ -34,9 +33,9 @@ def test_astroquery_mast(): """Test if the astroquery.mast service can complete a request""" service = 'Mast.Caom.Filtered' - params = {'columns': 'COUNT_BIG(*)', + params = {'columns': 'COUNT_BIG(*)', 'filters': [{"paramName": "obs_collection", - "values": ["JWST"]},], + "values": ["JWST"]}, ], 'pagesize': 1, 'page': 1} response = Mast.service_request_async(service, params) result = response[0].json() diff --git a/jwql/tests/test_msata_monitor.py b/jwql/tests/test_msata_monitor.py index fc0286d6c..c4e7b41ad 100644 --- a/jwql/tests/test_msata_monitor.py +++ b/jwql/tests/test_msata_monitor.py @@ -31,11 +31,10 @@ from jwql.instrument_monitors.nirspec_monitors.ta_monitors.msata_monitor import MSATA from jwql.database.database_interface import NIRSpecTAQueryHistory +from jwql.utils.constants import ON_GITHUB_ACTIONS from jwql.utils.utils import get_config, ensure_dir_exists from jwql.utils import monitor_utils, permissions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - # define the type of a Bokeh plot type bokeh_plot_type = type(figure()) @@ -53,38 +52,38 @@ def define_testdata(): msata_data : pandas dataframe """ msata_dict = { - # info taken from main_hdr dict - 'filename': ['jw09999001001_02101_00001_nrs1_uncal.fits'], - 'date_obs': ['2022-06-22'], - 'visit_id': ['V09999001001P0000000002101'], - 'tafilter': ['F110W'], - 'detector': ['NRS1'], - 'readout': ['NRSRAPID'], - 'subarray': ['FULL'], - # info taken from ta_hdr dict - 'num_refstars': [12], - 'ta_status': ['SUCCESSFUL'], - 'status_rsn': ['-999'], - 'v2halffacet': [-0.27568], - 'v3halffacet': [0.10975], - 'v2msactr': [378.523987], - 'v3msactr': [-428.374481], - 'lsv2offset': [-999.0], - 'lsv3offset': [-999.0], - 'lsoffsetmag': [-999.0], - 'lsrolloffset': [-999.0], - 'lsv2sigma': [-999.0], - 'lsv3sigma': [-999.0], - 'lsiterations': [-999], - 'guidestarid': ['-999'], - 'guidestarx': [-999.0], - 'guidestary': [-999.0], - 'guidestarroll': [-999.0], - 'samx': [-999.0], - 'samy': [-999.0], - 'samroll': [-999.0], - 'stars_in_fit': [-999] - } + # info taken from main_hdr dict + 'filename': ['jw09999001001_02101_00001_nrs1_uncal.fits'], + 'date_obs': ['2022-06-22'], + 'visit_id': ['V09999001001P0000000002101'], + 'tafilter': ['F110W'], + 'detector': ['NRS1'], + 'readout': ['NRSRAPID'], + 'subarray': ['FULL'], + # info taken from ta_hdr dict + 'num_refstars': [12], + 'ta_status': ['SUCCESSFUL'], + 'status_rsn': ['-999'], + 'v2halffacet': [-0.27568], + 'v3halffacet': [0.10975], + 'v2msactr': [378.523987], + 'v3msactr': [-428.374481], + 'lsv2offset': [-999.0], + 'lsv3offset': [-999.0], + 'lsoffsetmag': [-999.0], + 'lsrolloffset': [-999.0], + 'lsv2sigma': [-999.0], + 'lsv3sigma': [-999.0], + 'lsiterations': [-999], + 'guidestarid': ['-999'], + 'guidestarx': [-999.0], + 'guidestary': [-999.0], + 'guidestarroll': [-999.0], + 'samx': [-999.0], + 'samy': [-999.0], + 'samroll': [-999.0], + 'stars_in_fit': [-999] + } # add info from ta_table num_refstars = msata_dict['num_refstars'][0] msata_dict['box_peak_value'] = [[8000 for _ in range(num_refstars)]] diff --git a/jwql/tests/test_permissions.py b/jwql/tests/test_permissions.py index dd8878294..0fc6480d5 100755 --- a/jwql/tests/test_permissions.py +++ b/jwql/tests/test_permissions.py @@ -23,15 +23,11 @@ import os import pytest -from jwql.utils.permissions import set_permissions, has_permissions, \ - get_owner_string, get_group_string +from jwql.utils.permissions import set_permissions, has_permissions, get_owner_string, get_group_string # directory to be created and populated during tests running TEST_DIRECTORY = os.path.join(os.environ['HOME'], 'permission_test') -# Determine if tests are being run on Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - @pytest.fixture(scope="module") def test_directory(test_dir=TEST_DIRECTORY): diff --git a/jwql/tests/test_pipeline_tools.py b/jwql/tests/test_pipeline_tools.py index a79d687c8..ff072e0fb 100644 --- a/jwql/tests/test_pipeline_tools.py +++ b/jwql/tests/test_pipeline_tools.py @@ -24,13 +24,10 @@ import numpy as np from jwql.instrument_monitors import pipeline_tools +from jwql.utils.constants import ON_GITHUB_ACTIONS from jwql.utils.utils import get_config -# Determine if tests are being run on github actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - - @pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Requires access to central storage.') def test_completed_pipeline_steps(): """Test that the list of completed pipeline steps for a file is diff --git a/jwql/tests/test_preview_image.py b/jwql/tests/test_preview_image.py index ce0a7de5a..001371c96 100644 --- a/jwql/tests/test_preview_image.py +++ b/jwql/tests/test_preview_image.py @@ -30,16 +30,9 @@ from jwst.datamodels import dqflags from jwql.utils.preview_image import PreviewImage, crop_to_subarray +from jwql.utils.constants import ON_GITHUB_ACTIONS, ON_READTHEDOCS from jwql.utils.utils import get_config, ensure_dir_exists -# Determine if tests are being run on Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - -# Determine if the code is being run as part of a Readthedocs build -ON_READTHEDOCS = False -if 'READTHEDOCS' in os.environ: - ON_READTHEDOCS = os.environ['READTHEDOCS'] - def test_crop_to_subarray(): """Test that the code correctly crops larger arrays down to diff --git a/jwql/tests/test_protect_module.py b/jwql/tests/test_protect_module.py index 3bcafa5c1..28af6cd86 100644 --- a/jwql/tests/test_protect_module.py +++ b/jwql/tests/test_protect_module.py @@ -21,11 +21,9 @@ from jwql.utils import protect_module as pm from pytest import fixture, mark +from jwql.utils.constants import ON_GITHUB_ACTIONS from jwql.utils.protect_module import lock_module, _PID_LOCKFILE_KEY -# Determine if tests are being run on Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - @fixture def module_lock(): diff --git a/jwql/tests/test_readnoise_monitor.py b/jwql/tests/test_readnoise_monitor.py index f27a193ba..77fdce3d8 100644 --- a/jwql/tests/test_readnoise_monitor.py +++ b/jwql/tests/test_readnoise_monitor.py @@ -27,10 +27,9 @@ from jwql.database.database_interface import NIRCamReadnoiseQueryHistory, NIRCamReadnoiseStats, session from jwql.instrument_monitors.common_monitors import readnoise_monitor from jwql.tests.resources import has_test_db +from jwql.utils.constants import ON_GITHUB_ACTIONS from jwql.utils.utils import get_config -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - def test_determine_pipeline_steps(): """Test the correct pipeline steps are called""" diff --git a/jwql/tests/test_utils.py b/jwql/tests/test_utils.py index cd50c6a01..ecc34790b 100644 --- a/jwql/tests/test_utils.py +++ b/jwql/tests/test_utils.py @@ -26,13 +26,10 @@ from bokeh.plotting import figure import numpy as np +from jwql.utils.constants import ON_GITHUB_ACTIONS from jwql.utils.utils import copy_files, get_config, filename_parser, filesystem_path, save_png, _validate_config -# Determine if tests are being run on Github Actions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - - FILENAME_PARSER_TEST_DATA = [ # Test full path diff --git a/jwql/tests/test_wata_monitor.py b/jwql/tests/test_wata_monitor.py index 0b9099beb..91624147a 100644 --- a/jwql/tests/test_wata_monitor.py +++ b/jwql/tests/test_wata_monitor.py @@ -28,11 +28,10 @@ from jwql.instrument_monitors.nirspec_monitors.ta_monitors.wata_monitor import WATA from jwql.database.database_interface import NIRSpecTAQueryHistory +from jwql.utils.constants import ON_GITHUB_ACTIONS from jwql.utils.utils import get_config, ensure_dir_exists from jwql.utils import monitor_utils, permissions -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - # define the type of a Bokeh plot type bokeh_plot_type = type(figure()) @@ -50,48 +49,48 @@ def define_testdata(): wata_data : pandas dataframe """ wata_dict = { - # info taken from main_hdr dict - 'filename': ['jw09999001001_02101_00001_nrs1_uncal.fits'], - 'date_obs': ['2022-06-22'], - 'visit_id': ['V09999001001P0000000002101'], - 'tafilter': ['F110W'], - 'detector': ['NRS1'], - 'readout': ['NRSRAPID'], - 'subarray': ['FULL'], - # info taken from ta_hdr dict - 'ta_status': ['SUCCESSFUL'], - 'status_reason': ['-999'], - 'star_name': ['-999'], - 'star_ra': [-999.0], - 'star_dec': [-999.0], - 'star_mag': [-999.0], - 'star_catalog': [-999], - 'planned_v2': [-999.0], - 'planned_v3': [-999.0], - 'stamp_start_col': [-999], - 'stamp_start_row': [-999], - 'star_detector': ['-999'], - 'max_val_box': [-999.0], - 'max_val_box_col': [-999.0], - 'max_val_box_row': [-999.0], - 'iterations': [-999], - 'corr_col': [-999.0], - 'corr_row': [-999.0], - 'stamp_final_col': [-999.0], - 'stamp_final_row': [-999.0], - 'detector_final_col': [-999.0], - 'detector_final_row': [-999.0], - 'final_sci_x': [-999.0], - 'final_sci_y': [-999.0], - 'measured_v2': [-999.0], - 'measured_v3': [-999.0], - 'ref_v2': [-999.0], - 'ref_v3': [-999.0], - 'v2_offset': [-999.0], - 'v3_offset': [-999.0], - 'sam_x': [-999.0], - 'sam_y': [-999.0], - } + # info taken from main_hdr dict + 'filename': ['jw09999001001_02101_00001_nrs1_uncal.fits'], + 'date_obs': ['2022-06-22'], + 'visit_id': ['V09999001001P0000000002101'], + 'tafilter': ['F110W'], + 'detector': ['NRS1'], + 'readout': ['NRSRAPID'], + 'subarray': ['FULL'], + # info taken from ta_hdr dict + 'ta_status': ['SUCCESSFUL'], + 'status_reason': ['-999'], + 'star_name': ['-999'], + 'star_ra': [-999.0], + 'star_dec': [-999.0], + 'star_mag': [-999.0], + 'star_catalog': [-999], + 'planned_v2': [-999.0], + 'planned_v3': [-999.0], + 'stamp_start_col': [-999], + 'stamp_start_row': [-999], + 'star_detector': ['-999'], + 'max_val_box': [-999.0], + 'max_val_box_col': [-999.0], + 'max_val_box_row': [-999.0], + 'iterations': [-999], + 'corr_col': [-999.0], + 'corr_row': [-999.0], + 'stamp_final_col': [-999.0], + 'stamp_final_row': [-999.0], + 'detector_final_col': [-999.0], + 'detector_final_row': [-999.0], + 'final_sci_x': [-999.0], + 'final_sci_y': [-999.0], + 'measured_v2': [-999.0], + 'measured_v3': [-999.0], + 'ref_v2': [-999.0], + 'ref_v3': [-999.0], + 'v2_offset': [-999.0], + 'v3_offset': [-999.0], + 'sam_x': [-999.0], + 'sam_y': [-999.0], + } # create the additional arrays bool_status, status_colors = [], [] for tas, do_str in zip(wata_dict['ta_status'], wata_dict['date_obs']): diff --git a/jwql/utils/constants.py b/jwql/utils/constants.py index 9fcb790d0..d6791f489 100644 --- a/jwql/utils/constants.py +++ b/jwql/utils/constants.py @@ -30,6 +30,7 @@ import asdf import inflection +import os # Each amplifier is represented by 2 tuples, the first for x coordinates # and the second for y coordinates. Within each tuple are value for @@ -721,6 +722,12 @@ # Possible suffix types for AMI files NIRISS_AMI_SUFFIX_TYPES = ["amiavg", "aminorm", "ami", "psf-amiavg"] +# Determine if the code is being run as part of CI checking on github +ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') + +# Determine if the code is being run as part of a Readthedocs build +ON_READTHEDOCS = os.environ.get('READTHEDOCS', False) + # Base name for the file listing the preview images for a given instrument. # The complete name will have "_{instrument.lower}.txt" added to the end of this. PREVIEW_IMAGE_LISTFILE = "preview_image_inventory" @@ -921,7 +928,7 @@ class QueryConfigKeys: "nirspec": ['FULL'] + sorted(schema["properties"]["meta"]["properties"]["subarray"]["properties"]["name"]["anyOf"][6]['enum']), "miri": ['FULL'] + sorted(schema["properties"]["meta"]["properties"]["subarray"]["properties"]["name"]["anyOf"][1]['enum']), "fgs": ['FULL'] + sorted(schema["properties"]["meta"]["properties"]["subarray"]["properties"]["name"]["anyOf"][0]['enum']) - } +} # Filename suffixes that need to include the association value in the suffix in # order to identify the preview image file. This should only be crf and crfints, @@ -941,6 +948,15 @@ class QueryConfigKeys: # Possible suffix types for time-series exposures TIME_SERIES_SUFFIX_TYPES = ["phot", "whtlt"] +# Instrument Documentation Links +URL_DICT = { + "fgs": "https://jwst-docs.stsci.edu/jwst-observatory-hardware/jwst-fine-guidance-sensor", + "miri": "https://jwst-docs.stsci.edu/jwst-mid-infrared-instrument", + "niriss": "https://jwst-docs.stsci.edu/jwst-near-infrared-imager-and-slitless-spectrograph", + "nirspec": "https://jwst-docs.stsci.edu/jwst-near-infrared-spectrograph", + "nircam": "https://jwst-docs.stsci.edu/jwst-near-infrared-camera", +} + # Possible suffix types for WFS&C files WFSC_SUFFIX_TYPES = ["wfscmb"] @@ -954,12 +970,3 @@ class QueryConfigKeys: + WFSC_SUFFIX_TYPES + MSA_SUFFIX ) - -# Instrument Documentation Links -URL_DICT = { - "fgs": "https://jwst-docs.stsci.edu/jwst-observatory-hardware/jwst-fine-guidance-sensor", - "miri": "https://jwst-docs.stsci.edu/jwst-mid-infrared-instrument", - "niriss": "https://jwst-docs.stsci.edu/jwst-near-infrared-imager-and-slitless-spectrograph", - "nirspec": "https://jwst-docs.stsci.edu/jwst-near-infrared-spectrograph", - "nircam": "https://jwst-docs.stsci.edu/jwst-near-infrared-camera", -} diff --git a/jwql/utils/mast_utils.py b/jwql/utils/mast_utils.py index 6524a8c6a..446645800 100644 --- a/jwql/utils/mast_utils.py +++ b/jwql/utils/mast_utils.py @@ -24,12 +24,12 @@ import pandas as pd from jwql.utils.constants import JWST_DATAPRODUCTS, JWST_INSTRUMENT_NAMES, JWST_INSTRUMENT_NAMES_MIXEDCASE, MAST_QUERY_LIMIT +from jwql.utils.constants import ON_GITHUB_ACTIONS from jwql.utils.permissions import set_permissions from jwql.utils.utils import ensure_dir_exists, get_config from jwql.utils.plotting import bar_chart -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') if not ON_GITHUB_ACTIONS: Mast._portal_api_connection.MAST_REQUEST_URL = get_config()['mast_request_url'] diff --git a/jwql/utils/monitor_utils.py b/jwql/utils/monitor_utils.py index f5c673cbd..49218c6fa 100644 --- a/jwql/utils/monitor_utils.py +++ b/jwql/utils/monitor_utils.py @@ -24,6 +24,7 @@ from jwql.database.database_interface import Monitor, engine from jwql.utils.constants import ASIC_TEMPLATES, JWST_DATAPRODUCTS, MAST_QUERY_LIMIT +from jwql.utils.constants import ON_GITHUB_ACTIONS, ON_READTHEDOCS from jwql.utils.logging_functions import configure_logging, get_log_status from jwql.utils import mast_utils from jwql.utils.utils import filename_parser @@ -33,12 +34,6 @@ # a MAST query. Mast._portal_api_connection.PAGESIZE = MAST_QUERY_LIMIT -# Determine if the code is being run as part of a github action or Readthedocs build -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') -ON_READTHEDOCS = False -if 'READTHEDOCS' in os.environ: # pragma: no cover - ON_READTHEDOCS = os.environ['READTHEDOCS'] - if not ON_GITHUB_ACTIONS and not ON_READTHEDOCS: # These lines are needed in order to use the Django models in a standalone # script (as opposed to code run as a result of a webpage request). If these diff --git a/jwql/utils/preview_image.py b/jwql/utils/preview_image.py index f86c10272..088996ab9 100755 --- a/jwql/utils/preview_image.py +++ b/jwql/utils/preview_image.py @@ -43,6 +43,7 @@ import numpy as np from jwql.utils import permissions +from jwql.utils.constants import ON_GITHUB_ACTIONS, ON_READTHEDOCS from jwql.utils.utils import get_config # Use the 'Agg' backend to avoid invoking $DISPLAY @@ -52,17 +53,9 @@ import matplotlib.colors as colors # noqa from matplotlib.ticker import AutoMinorLocator # noqa -# Only import jwst if not running from readthedocs -# Determine if the code is being run as part of a Readthedocs build -ON_READTHEDOCS = False -if 'READTHEDOCS' in os.environ: - ON_READTHEDOCS = os.environ['READTHEDOCS'] - if not ON_READTHEDOCS: from jwst.datamodels import dqflags -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - if not ON_GITHUB_ACTIONS and not ON_READTHEDOCS: CONFIGS = get_config() @@ -763,6 +756,7 @@ def expand_for_i2d(array, xdim, ydim): else: return array + def nan_to_zero(image): """Set any pixels with a value of NaN to zero diff --git a/jwql/utils/utils.py b/jwql/utils/utils.py index e9db05557..b5d2e5a46 100644 --- a/jwql/utils/utils.py +++ b/jwql/utils/utils.py @@ -53,12 +53,9 @@ FILE_GUIDESTAR_ATTMPT_LEN_MAX, FILE_OBS_LEN, FILE_PARALLEL_SEQ_ID_LEN, \ FILE_PROG_ID_LEN, FILE_SEG_LEN, FILE_SOURCE_ID_LEN, FILE_SUFFIX_TYPES, \ FILE_TARG_ID_LEN, FILE_VISIT_GRP_LEN, FILE_VISIT_LEN, FILETYPE_WO_STANDARD_SUFFIX, \ - JWST_INSTRUMENT_NAMES_SHORTHAND - + JWST_INSTRUMENT_NAMES_SHORTHAND, ON_GITHUB_ACTIONS __location__ = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - def _validate_config(config_file_dict): """Check that the config.json file contains all the needed entries with diff --git a/jwql/website/apps/jwql/data_containers.py b/jwql/website/apps/jwql/data_containers.py index db6fba1fd..5acd4fe87 100644 --- a/jwql/website/apps/jwql/data_containers.py +++ b/jwql/website/apps/jwql/data_containers.py @@ -59,6 +59,7 @@ from jwql.utils.constants import JWST_INSTRUMENT_NAMES_MIXEDCASE, JWST_INSTRUMENT_NAMES from jwql.utils.constants import REPORT_KEYS_PER_INSTRUMENT from jwql.utils.constants import SUFFIXES_TO_ADD_ASSOCIATION, SUFFIXES_WITH_AVERAGED_INTS, QueryConfigKeys +from jwql.utils.constants import ON_GITHUB_ACTIONS, ON_READTHEDOCS from jwql.utils.credentials import get_mast_token from jwql.utils.permissions import set_permissions from jwql.utils.utils import get_rootnames_for_instrument_proposal @@ -68,15 +69,6 @@ # a MAST query. Mast._portal_api_connection.PAGESIZE = MAST_QUERY_LIMIT -# astroquery.mast import that depends on value of auth_mast -# this import has to be made before any other import of astroquery.mast -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~') - -# Determine if the code is being run as part of a Readthedocs build -ON_READTHEDOCS = False -if 'READTHEDOCS' in os.environ: # pragma: no cover - ON_READTHEDOCS = os.environ['READTHEDOCS'] - if not ON_GITHUB_ACTIONS and not ON_READTHEDOCS: # These lines are needed in order to use the Django models in a standalone @@ -412,8 +404,7 @@ def get_available_suffixes(all_suffixes, return_untracked=True): untracked_suffixes = set(all_suffixes) for poss_suffix in EXPOSURE_PAGE_SUFFIX_ORDER: if 'crf' not in poss_suffix: - if (poss_suffix in all_suffixes - and poss_suffix not in suffixes): + if (poss_suffix in all_suffixes and poss_suffix not in suffixes): suffixes.append(poss_suffix) untracked_suffixes.remove(poss_suffix) else: @@ -423,8 +414,7 @@ def get_available_suffixes(all_suffixes, return_untracked=True): # So in this case, we strip the e.g. o001 from the # suffixes and check which list elements match. for image_suffix in all_suffixes: - if (image_suffix.endswith(poss_suffix) - and image_suffix not in suffixes): + if (image_suffix.endswith(poss_suffix) and image_suffix not in suffixes): suffixes.append(image_suffix) untracked_suffixes.remove(image_suffix) diff --git a/jwql/website/apps/jwql/tests/test_context_processors.py b/jwql/website/apps/jwql/tests/test_context_processors.py index 1d4fc5951..b1ed31510 100644 --- a/jwql/website/apps/jwql/tests/test_context_processors.py +++ b/jwql/website/apps/jwql/tests/test_context_processors.py @@ -24,7 +24,7 @@ import os from unittest import skipIf -ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') +from jwql.utils.constants import ON_GITHUB_ACTIONS if not ON_GITHUB_ACTIONS: from jwql.website.apps.jwql import context_processors