From 9563ea5cbffface520d0b3bd83a19ec6b940b022 Mon Sep 17 00:00:00 2001 From: Jeremy Fee <jmfee@usgs.gov> Date: Fri, 26 Jun 2020 10:40:19 -0600 Subject: [PATCH 1/5] Update spreadsheet relative time parsing, os.walk usage --- geomagio/residual/SpreadsheetAbsolutesFactory.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/geomagio/residual/SpreadsheetAbsolutesFactory.py b/geomagio/residual/SpreadsheetAbsolutesFactory.py index 889753e03..1cf007856 100644 --- a/geomagio/residual/SpreadsheetAbsolutesFactory.py +++ b/geomagio/residual/SpreadsheetAbsolutesFactory.py @@ -217,13 +217,12 @@ def parse_relative_time(base_date: str, time: str) -> UTCDateTime: Arguments --------- base_date: date when time occurs (YYYYMMDD) - time: time on base_date (HHMMSS) - left padded with zeros to 6 characters + time: time on base_date (HHMMSS) or (HHMM) """ try: - return UTCDateTime(f"{base_date}T{time:06}") + return UTCDateTime(f"{base_date}T{time}") except Exception as e: - print(f"error parsing relative date '{base_date}T{time:06}': {e}") + print(f"error parsing relative date '{base_date}T{time}': {e}") return None @@ -255,9 +254,9 @@ class SpreadsheetAbsolutesFactory(object): for year in range(starttime.year, endtime.year + 1): # start in observatory year directory to scan fewer files observatory_directory = os.path.join( - self.base_directory, observatory, f"{year}", observatory + self.base_directory, observatory, f"{year}" ) - for (dirpath, filenames) in os.walk(observatory_directory): + for (dirpath, _, filenames) in os.walk(observatory_directory): for filename in filenames: if start_filename <= filename < end_filename: readings.append( @@ -284,7 +283,7 @@ class SpreadsheetAbsolutesFactory(object): and self._parse_measurements( measurement_sheet, metadata["date"], metadata["precision"] ) - or None + or [] ) mark_azimuth = metadata["mark_azimuth"] return Reading( -- GitLab From 3df6b2b0afa144f6c2dba93f5b7992f2ea133fd5 Mon Sep 17 00:00:00 2001 From: Jeremy Fee <jmfee@usgs.gov> Date: Fri, 26 Jun 2020 10:40:36 -0600 Subject: [PATCH 2/5] Use 2 decimals in cal files --- geomagio/residual/CalFileFactory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geomagio/residual/CalFileFactory.py b/geomagio/residual/CalFileFactory.py index 64a316b96..5b626ca2f 100644 --- a/geomagio/residual/CalFileFactory.py +++ b/geomagio/residual/CalFileFactory.py @@ -43,7 +43,7 @@ class CalFileFactory(object): absolute, baseline = absolute * 60, baseline * 60 out.write( # this is one line... f"{c.starttime.datetime:%H%M}-{c.endtime.datetime:%H%M}" - f" c{baseline:9.1f}{absolute:9.1f}\n" + f" c{baseline:9.2f}{absolute:9.2f}\n" ) # add new line to end out.write("\n") -- GitLab From e3d35e248543109079f2c190ff674a786effaa11 Mon Sep 17 00:00:00 2001 From: Jeremy Fee <jmfee@usgs.gov> Date: Fri, 26 Jun 2020 12:11:23 -0600 Subject: [PATCH 3/5] Use conda image --- .gitlab-ci.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 87aebece8..181964b7b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,21 +15,12 @@ variables: .check_code: cache: {} - image: usgs/centos:latest + image: ${DEVOPS_REGISTRY}usgs/conda:latest script: - - yum install -y wget which - - wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - conda config --set always_yes yes --set changeps1 no - - conda update --yes conda - - conda info -a # Install Project Dependencies - conda config --add channels conda-forge - conda install python=${PYTHON_VERSION} obspy pycurl - pip install pipenv - - export LC_ALL=C.UTF-8 - - export LANG=C.UTF-8 - pipenv --site-packages install --dev --pre --skip-lock # Run Code Checks - pipenv run black --check . -- GitLab From d644bbfe2cad51c79d0e566ba93ff336e08756bd Mon Sep 17 00:00:00 2001 From: Jeremy Fee <jmfee@usgs.gov> Date: Fri, 26 Jun 2020 12:14:17 -0600 Subject: [PATCH 4/5] Add conda to path --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 181964b7b..ae6f47229 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,6 +17,8 @@ variables: cache: {} image: ${DEVOPS_REGISTRY}usgs/conda:latest script: + # Add conda to path + - source /etc/profile.d/conda.sh # Install Project Dependencies - conda config --add channels conda-forge - conda install python=${PYTHON_VERSION} obspy pycurl -- GitLab From 398f862a1d9cf99265980f23d3ee5b09d8960a84 Mon Sep 17 00:00:00 2001 From: Jeremy Fee <jmfee@usgs.gov> Date: Fri, 26 Jun 2020 12:19:59 -0600 Subject: [PATCH 5/5] Fix coverage command --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae6f47229..ee2f09912 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,7 +26,7 @@ variables: - pipenv --site-packages install --dev --pre --skip-lock # Run Code Checks - pipenv run black --check . - - pipenv run pytest --cov-report xml:cov.xml --cov=test/ + - pipenv run pytest --cov-report xml:cov.xml --cov=geomagio artifacts: paths: - cov.xml -- GitLab