Skip to content

Commit

Permalink
pytz -> datetime.timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanLaserGit committed Oct 24, 2024
1 parent a8e75d2 commit 917ab4f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/forcingprocessor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Test with pytest
run: |
cd forcingprocessor
python -m pytest -vv --deselect="tests/test_forcingprocessor.py::test_google_cloud_storage" --deselect="tests/test_forcingprocessor.py::test_gcs" --deselect="tests/test_forcingprocessor.py::test_gs" --deselect="tests/test_forcingprocessor.py::test_ciroh_zarr" --deselect="tests/test_forcingprocessor.py::test_nomads_post_processed" --deselect="tests/test_forcingprocessor.py::test_retro_ciroh_zarr" --deselect="tests/test_forcingprocessor.py::test_noaa_nwm_pds_https_analysis_assim" --deselect="tests/test_hf2ds.py" --deselect="tests/test_plotter.py"
python -m pytest -vv --deselect="tests/test_forcingprocessor.py::test_google_cloud_storage" --deselect="tests/test_forcingprocessor.py::test_gcs" --deselect="tests/test_forcingprocessor.py::test_gs" --deselect="tests/test_forcingprocessor.py::test_ciroh_zarr" --deselect="tests/test_forcingprocessor.py::test_nomads_post_processed" --deselect="tests/test_forcingprocessor.py::test_retro_ciroh_zarr" --deselect="tests/test_hf2ds.py" --deselect="tests/test_plotter.py"
python -m pytest -vv tests/test_hf2ds.py
python -m pytest -vv tests/test_plotter.py
python -m pytest -vv -k test_google_cloud_storage
Expand Down
5 changes: 2 additions & 3 deletions forcingprocessor/tests/test_forcingprocessor.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os
from pathlib import Path
from datetime import datetime
from datetime import datetime
from datetime import timezone
from forcingprocessor.processor import prep_ngen_data
from forcingprocessor.nwm_filenames_generator import generate_nwmfiles
import pytz as tz
import pytest

HF_VERSION="v2.1.1"
date = datetime.now(tz.timezone('US/Eastern'))
date = datetime.now(timezone.utc)
date = date.strftime('%Y%m%d')
hourminute = '0000'
test_dir = Path(__file__).parent
Expand Down
22 changes: 11 additions & 11 deletions python_tools/tests/test_configurer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os, pytest, json
from datetime import datetime
import pytz as tz
from datetime import datetime, timezone
from python_tools.configure_datastream import create_confs

SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -110,7 +109,7 @@ def test_conf_daily():
with open(REALIZATION_RUN,'r') as fp:
data = json.load(fp)
start = datetime.strptime(data['time']['start_time'],"%Y-%m-%d %H:%M:%S")
assert start.day == datetime.now(tz.timezone('US/Eastern')).day
assert start.day == datetime.now(timezone.utc).day

with open(CONF_NWM,'r') as fp:
data = json.load(fp)
Expand Down Expand Up @@ -142,7 +141,7 @@ def test_conf_daily_short_range():
with open(REALIZATION_RUN,'r') as fp:
data = json.load(fp)
start = datetime.strptime(data['time']['start_time'],"%Y-%m-%d %H:%M:%S")
assert start.day == datetime.now(tz.timezone('US/Eastern')).day
assert start.day == datetime.now(timezone.utc).day

with open(CONF_NWM,'r') as fp:
data = json.load(fp)
Expand All @@ -159,7 +158,7 @@ def test_conf_daily_medium_range():
with open(REALIZATION_RUN,'r') as fp:
data = json.load(fp)
start = datetime.strptime(data['time']['start_time'],"%Y-%m-%d %H:%M:%S")
assert start.day == datetime.now(tz.timezone('US/Eastern')).day
assert start.day == datetime.now(timezone.utc).day

with open(CONF_NWM,'r') as fp:
data = json.load(fp)
Expand All @@ -176,7 +175,7 @@ def test_conf_daily_noamds():
with open(REALIZATION_RUN,'r') as fp:
data = json.load(fp)
start = datetime.strptime(data['time']['start_time'],"%Y-%m-%d %H:%M:%S")
assert start.day == datetime.now(tz.timezone('US/Eastern')).day
assert start.day == datetime.now(timezone.utc).day

with open(CONF_NWM,'r') as fp:
data = json.load(fp)
Expand All @@ -193,7 +192,7 @@ def test_conf_daily_noamds_postprocessed():
with open(REALIZATION_RUN,'r') as fp:
data = json.load(fp)
start = datetime.strptime(data['time']['start_time'],"%Y-%m-%d %H:%M:%S")
assert start.day == datetime.now(tz.timezone('US/Eastern')).day
assert start.day == datetime.now(timezone.utc).day

with open(CONF_NWM,'r') as fp:
data = json.load(fp)
Expand All @@ -213,7 +212,7 @@ def test_conf_daily_assim_split_vpu_s3out():
with open(REALIZATION_RUN,'r') as fp:
data = json.load(fp)
start = datetime.strptime(data['time']['start_time'],"%Y-%m-%d %H:%M:%S")
assert start.day == datetime.now(tz.timezone('US/Eastern')).day
assert start.day == datetime.now(timezone.utc).day

with open(CONF_NWM,'r') as fp:
data = json.load(fp)
Expand All @@ -240,12 +239,13 @@ def test_conf_daily_assim_extend_split_vpu_s3out():
with open(REALIZATION_RUN,'r') as fp:
data = json.load(fp)
start = datetime.strptime(data['time']['start_time'],"%Y-%m-%d %H:%M:%S")
assert start.day == datetime.now(tz.timezone('US/Eastern')).day
assert start.day == datetime.now(timezone.utc).day

with open(CONF_NWM,'r') as fp:
data = json.load(fp)
assert data['urlbaseinput'] == 7
assert data['runinput'] == 6
assert data['urlbaseinput'] == 7
assert data['runinput'] == 6
assert data['fcst_cycle'][0] == 16
assert len(data['lead_time'] ) == 28

with open(CONF_FP,'r') as fp:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time
import re
import datetime
import pytz as tz
from datetime import timezone

client_s3 = boto3.client('s3')

Expand Down Expand Up @@ -37,7 +37,7 @@ def lambda_handler(event, context):
if bucket is None or prefix is None:
raise Exception(f'User specified ii_check_s3, but no s3_bucket or s3_prefix were not found in commands')
if "DAILY" in prefix:
prefix = re.sub(r"\DAILY",datetime.now(tz.timezone('US/Eastern')).strftime('%Y%m%d'),prefix)
prefix = re.sub(r"\DAILY",datetime.now(timezone.utc).strftime('%Y%m%d'),prefix)
print(f'Checking if any objects with prefix {prefix} exists in {bucket}')
wait_for_object_existence(bucket, prefix)
else:
Expand Down

0 comments on commit 917ab4f

Please sign in to comment.