From c716e6632f55200786c1fc4080403d4637e39972 Mon Sep 17 00:00:00 2001 From: Sharon Goliath Date: Wed, 28 Jun 2023 14:27:35 -0700 Subject: [PATCH 1/4] CADC-12637 - make contentType definition more flexible for text/plain. --- caom2utils/caom2utils/data_util.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/caom2utils/caom2utils/data_util.py b/caom2utils/caom2utils/data_util.py index 171fb504..3a767075 100644 --- a/caom2utils/caom2utils/data_util.py +++ b/caom2utils/caom2utils/data_util.py @@ -354,9 +354,8 @@ def get_file_encoding(fqn): def get_file_type(fqn): """Basic header extension to content_type lookup.""" - if (fqn.endswith('.header') or fqn.endswith('.txt') or - fqn.endswith('.cat') or fqn.endswith('.dat')): - return 'text/plain' + if (fqn.endswith('.fits') or fqn.endswith('.fits.fz') ): + return 'application/fits' elif fqn.endswith('.gif'): return 'image/gif' elif fqn.endswith('.png'): @@ -370,7 +369,7 @@ def get_file_type(fqn): elif fqn.endswith('.hdf5') or fqn.endswith('.h5'): return 'application/x-hdf5' else: - return 'application/fits' + return 'text/plain' def make_headers_from_string(fits_header): From be10c9d32f0219eb3ec7d24202175ea9b1e729ed Mon Sep 17 00:00:00 2001 From: Sharon Goliath Date: Thu, 13 Jul 2023 14:11:22 -0700 Subject: [PATCH 2/4] CADC-12637 - code review comments, flake8. --- caom2utils/caom2utils/caom2blueprint.py | 10 +++++----- caom2utils/caom2utils/data_util.py | 15 ++++++++------- caom2utils/setup.cfg | 5 ++++- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/caom2utils/caom2utils/caom2blueprint.py b/caom2utils/caom2utils/caom2blueprint.py index 1c63c820..15eb22bd 100755 --- a/caom2utils/caom2utils/caom2blueprint.py +++ b/caom2utils/caom2utils/caom2blueprint.py @@ -3935,7 +3935,7 @@ def augment_custom(self, chunk): return try: custom_axis_length = self._get_axis_length(custom_axis_index + 1) - except ValueError as e: + except ValueError: self.logger.debug('No WCS Custom axis.function') return @@ -3972,7 +3972,7 @@ def augment_energy(self, chunk): return try: energy_axis_length = self._get_axis_length(energy_axis_index + 1) - except ValueError as e: + except ValueError: self.logger.debug('No WCS Energy axis.function') return @@ -4070,7 +4070,7 @@ def augment_temporal(self, chunk): try: axis_length = self._get_axis_length(time_axis_index + 1) - except ValueError as e: + except ValueError: self.logger.debug('No WCS Temporal axis.function') return @@ -4111,7 +4111,7 @@ def augment_polarization(self, chunk): try: axis_length = self._get_axis_length(polarization_axis_index + 1) - except ValueError as e: + except ValueError: self.logger.debug('No WCS Polarization axis.function') return @@ -4216,7 +4216,7 @@ def _get_dimension(self, xindex, yindex): try: xindex_axis_length = self._get_axis_length(xindex + 1) yindex_axis_length = self._get_axis_length(yindex + 1) - except ValueError as e: + except ValueError: self.logger.debug('No WCS Energy axis.function') return None aug_dim1 = _to_int(xindex_axis_length) diff --git a/caom2utils/caom2utils/data_util.py b/caom2utils/caom2utils/data_util.py index 3a767075..d1fd23c3 100644 --- a/caom2utils/caom2utils/data_util.py +++ b/caom2utils/caom2utils/data_util.py @@ -354,19 +354,20 @@ def get_file_encoding(fqn): def get_file_type(fqn): """Basic header extension to content_type lookup.""" - if (fqn.endswith('.fits') or fqn.endswith('.fits.fz') ): + lower_fqn = fqn.lower() + if (lower_fqn.endswith('.fits') or lower_fqn.endswith('.fits.fz')): return 'application/fits' - elif fqn.endswith('.gif'): + elif lower_fqn.endswith('.gif'): return 'image/gif' - elif fqn.endswith('.png'): + elif lower_fqn.endswith('.png'): return 'image/png' - elif fqn.endswith('.jpg'): + elif lower_fqn.endswith('.jpg'): return 'image/jpeg' - elif fqn.endswith('.tar.gz'): + elif lower_fqn.endswith('.tar.gz'): return 'application/x-tar' - elif fqn.endswith('.csv'): + elif lower_fqn.endswith('.csv'): return 'text/csv' - elif fqn.endswith('.hdf5') or fqn.endswith('.h5'): + elif lower_fqn.endswith('.hdf5') or fqn.endswith('.h5'): return 'application/x-hdf5' else: return 'text/plain' diff --git a/caom2utils/setup.cfg b/caom2utils/setup.cfg index 4ebe3e25..233ccd50 100644 --- a/caom2utils/setup.cfg +++ b/caom2utils/setup.cfg @@ -33,7 +33,7 @@ url = https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/caom2 edit_on_github = False github_project = opencadc/caom2tools # version should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386) -version = 1.7 +version = 1.7.1 [options] install_requires = @@ -52,6 +52,9 @@ test = flake8>=3.9 xml-compare>=1.0.5 +[flake8] +max-line-length = 120 + [entry_points] fits2caom2 = caom2utils.legacy:main_app caom2gen = caom2utils.caom2blueprint:caom2gen From 02ce777c011822c69e2272e281a374c1070a0f69 Mon Sep 17 00:00:00 2001 From: Sharon Goliath Date: Thu, 20 Jul 2023 15:19:01 -0700 Subject: [PATCH 3/4] CADC-12637 - increment cibuild versions. --- .github/workflows/cibuild.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml index 1a7afba7..b38c38fe 100644 --- a/.github/workflows/cibuild.yml +++ b/.github/workflows/cibuild.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install hdf5 library run: sudo apt-get install -y libhdf5-dev @@ -21,9 +21,9 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python 3.10 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: "3.10" - name: Install tox @@ -49,11 +49,11 @@ jobs: package: caom2utils steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install tox @@ -70,9 +70,9 @@ jobs: runs-on: ubuntu-latest needs: tests steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python 3.10 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: "3.10" - name: Setup Graphviz @@ -96,9 +96,9 @@ jobs: runs-on: ubuntu-latest if: contains(github.ref, '=') steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Determine the package From 4be9574034226f6f30330b7673fad56e9b88d1e3 Mon Sep 17 00:00:00 2001 From: Sharon Goliath Date: Thu, 20 Jul 2023 15:30:30 -0700 Subject: [PATCH 4/4] CADC-12637 - remove h5py dependencies that are failing to install. --- .github/workflows/cibuild.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml index b38c38fe..4fac1bf1 100644 --- a/.github/workflows/cibuild.yml +++ b/.github/workflows/cibuild.yml @@ -14,8 +14,6 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v3 - - name: Install hdf5 library - run: sudo apt-get install -y libhdf5-dev egginfo: needs: build @@ -57,8 +55,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install tox - # pytest-runner required to support deprecated Python3.5 - run: python -m pip install --upgrade tox pytest-runner + run: python -m pip install --upgrade tox - name: Test ${{ matrix.package }} run: | # add py and remove the "." from python-version in order to get the tox_target