Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions .pre-commit-config.yaml

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks to resolve the issue you had with poetry trying to run locally. Good!

Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,30 @@ repos:
hooks:
- id: black
name: black
entry: poetry run black

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want a separate PR if the yaml needs to be changed?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say so, I had started one to fix the issue with the formatting library versions being different based on version of python running.

I.e. your local vs CI versions

But this was also blocking the local tests from running.

Should we pick this out into its own PR? @msweier

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change the yaml in order to pass the commit checks, otherwise it could not find poetry.

I don't know if this is an everybody problem or just a me problem.

language: system
entry: black
language: python
additional_dependencies: [black]
types: [file, python]
exclude: ^cwmscli/_generated/ownership_data\.py$

- id: isort
name: isort
entry: poetry run isort
language: system
entry: isort
language: python
additional_dependencies: [isort]
types: [file, python]
exclude: ^cwmscli/_generated/ownership_data\.py$

- id: yamlfix
name: yamlfix
entry: poetry run yamlfix
language: system
entry: yamlfix
language: python
additional_dependencies: [yamlfix]
types: [file, yaml]

- id: ownership-sync
name: generated ownership files
entry: poetry run python scripts/sync_ownership.py --check
language: system
entry: python scripts/sync_ownership.py --check
language: python
additional_dependencies: [poetry]
pass_filenames: false
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
repos:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This .pre-cmmit-file.cong.yaml.org is a copy of the original and probably was included by accident.

- repo: local
hooks:
- id: black
name: black
entry: poetry run black
language: system
types: [file, python]
exclude: ^cwmscli/_generated/ownership_data\.py$

- id: isort
name: isort
entry: poetry run isort
language: system
types: [file, python]
exclude: ^cwmscli/_generated/ownership_data\.py$

- id: yamlfix
name: yamlfix
entry: poetry run yamlfix
language: system
types: [file, yaml]

- id: ownership-sync
name: generated ownership files
entry: poetry run python scripts/sync_ownership.py --check
language: system
pass_filenames: false
25 changes: 25 additions & 0 deletions cwmscli/usgs/getusgs_cda.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import re
from datetime import datetime, timedelta
from typing import Optional

Expand Down Expand Up @@ -370,6 +371,30 @@ def CWMS_writeData(USGS_ts, USGS_data, USGS_data_method, days_back):
office = row["office-id"]
values["quality-code"] = 0

# check for non irregular data interval and resample data to that interval
if not (
"~" in ts_id.split(".")[3] or ts_id.split(".")[3] == "0"
):
interval_number = re.match(
r"^(\d+)(.*)", ts_id.split(".")[3]
).group(1)
interval_type = re.match(
r"^(\d+)(.*)", ts_id.split(".")[3]
).group(2)
if interval_type == "Minutes":
interval_initial = "min"
else:
interval_initial = interval_type[0]
values_dt = values.copy()
values_dt["date-time"] = pd.to_datetime(
values_dt["date-time"]
)
values_dt.set_index("date-time", inplace=True)
values_new = values_dt.resample(
interval_number + interval_initial
).first()
values = values_new.reset_index()

# write values to CWMS database
try:
data = cwms.timeseries_df_to_json(
Expand Down
Loading