Skip to content

Commit

Permalink
Feature/first implementation (#1)
Browse files Browse the repository at this point in the history
* fix pylint

* more initial testing

* temp tests

* test

* testing

* update print messages on what collection is being sync

* fix umm v auto sync conflicts

* update cron to run at midnight pst
  • Loading branch information
sliu008 authored Jan 31, 2024
1 parent cf40ab8 commit 8a279a3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Umm V Auto Sync
# Controls when the workflow will run
on:
schedule:
- cron: '0 0 * * *' # Set the cron schedule for nightly build (UTC time)
- cron: '0 8 * * *' # Set the cron schedule for midnight PST
branches:
- main
workflow_dispatch:
Expand All @@ -13,7 +13,7 @@ on:
jobs:
# First job in the workflow installs and verifies the software
build:
name: Build, Test, Verify, Publish
name: Build, Test
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
Expand All @@ -37,9 +37,21 @@ jobs:
#########################################################################
# NOTE: This step is platform-specific
# These are gradle-specific steps for installing the application
- name: Poetry Steps
- name: Install Software
working-directory: umm_v_auto
run: |
poetry install
poetry run pylint podaac
poetry run flake8 podaac
poetry run flake8 podaac
#########################################################################
# UMM V Auto Sync
#########################################################################
- name: UMM V Auto Sync
working-directory: umm_v_auto
env:
UAT_TOKEN_TEMP: ${{ secrets.LAUNCHPAD_TOKEN_UAT }}
OPS_TOKEN_TEMP: ${{ secrets.LAUNCHPAD_TOKEN_OPS }}
run: |
poetry run python podaac/umm_v_auto_sync.py -ut $UAT_TOKEN_TEMP -ot $OPS_TOKEN_TEMP
19 changes: 10 additions & 9 deletions umm_v_auto/podaac/umm_v_auto_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def search_source(search_api: str, concept_id: str, **kwargs) -> dict:
try:
source_coll_meta = search(
f"{search_api}/collections.umm_json", params=source_coll_params).get("items")[0]
except (KeyError, IndexError) as e: # pylint: disable = unused-variable
except (KeyError, IndexError) as e: # noqa: F841 pylint: disable = unused-variable
raise Exception(
f"ERROR! Source collection was not found in CMR ({source_cmr}) for the input concept-id ({source_coll})")
except JSONDecodeError as e:
f"ERROR! Source collection was not found in CMR ({source_cmr}) for the input concept-id ({source_coll})") # noqa: F821
except json.JSONDecodeError as e: # noqa: F841
raise Exception(
f"ERROR! Source collection metadata could not be accessed from CMR ({source_cmr}) due to http request failure")
f"ERROR! Source collection metadata could not be accessed from CMR ({source_cmr}) due to http request failure") # noqa: F821

if 'associations' in source_coll_meta.get("meta"):
if 'variables' in source_coll_meta.get("meta").get("associations"):
Expand Down Expand Up @@ -72,7 +72,7 @@ def _ingest(record_data: dict) -> dict:
'Accept': "application/json",
}).json()
ummvar_concept_id = response.get("concept-id")
except json.JSONDecodeError as e: # pylint: disable = unused-variable
except json.JSONDecodeError as e: # # noqa: F841 pylint: disable = unused-variable
print(
f"ERROR! {ummvar_native_id} -- TODO: Handle failed requests w/ logic to retry errors that appear transient.")
except Exception as e: # Skip exceptions so the previous api repsonses are retained.
Expand Down Expand Up @@ -105,12 +105,12 @@ def parse_args():

parser.add_argument('-ut', '--uat_token',
help='launchpad token file for uat',
required=False,
required=True,
metavar='')

parser.add_argument('-ot', '--ops_token',
help='launchpad token file for ops',
required=False,
required=True,
metavar='')

args = parser.parse_args()
Expand All @@ -130,7 +130,7 @@ def get_ops_collection_concept_id(env, collection_name, headers):
collections_query = requests.get(url, headers=headers, params={
'page_size': 2000}).json()['feed']['entry']

if collection_name not in ops_collection_name_id:
if collection_name not in ops_collection_name_id and len(collections_query) > 0:

variables = collections_query[0].get(
"associations").get("variables", [])
Expand Down Expand Up @@ -251,4 +251,5 @@ def sync_ops_umm_v_to_uat(ops_concept_id, ops_token, uat_token):
if uat_umm_v == 0:
ops_concept_id = ops_collection_name_id[collection].get(
'concept_id')
sync_ops_umm_v_to_uat(ops_concept_id, _args.ops_token, _args.uat_token)
print(f"Sync collection {collection}")
sync_ops_umm_v_to_uat(ops_concept_id, _args.ops_token, _args.uat_token)

0 comments on commit 8a279a3

Please sign in to comment.