Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
126ffa9
Merge branch 'pre-production' into transfer
jirhiker Sep 11, 2025
168e005
feat: enhance logging and performance tracking in transfer scripts
jirhiker Sep 18, 2025
50ef63d
Formatting changes
jirhiker Sep 18, 2025
5a0b023
Merge branch 'staging' into jir-transfer-timing
jirhiker Sep 22, 2025
6ecbf9a
feat: enhance date handling and error logging in transfer scripts
jirhiker Sep 22, 2025
380b2ac
Merge branch 'jir-transfer-timing' into transfer
jirhiker Sep 22, 2025
e19d360
Formatting changes
jirhiker Sep 22, 2025
8aff1a4
feat: refactor transfer functions and add main_transfer endpoint
jirhiker Sep 23, 2025
1fcf40f
Formatting changes
jirhiker Sep 23, 2025
c73f881
feat: rename main_transfer endpoint to transfer_all for clarity
jirhiker Sep 23, 2025
49d5a79
feat: rename main_transfer endpoint to transfer_all for clarity
jirhiker Sep 23, 2025
e5508cb
feat: update Procfile to run main_transfer script directly
jirhiker Sep 23, 2025
b3997d1
feat: update Procfile to run main_transfer script directly
jirhiker Sep 23, 2025
3ce9e24
feat: update Procfile to use python3 for main_transfer script
jirhiker Sep 23, 2025
2eb3c11
feat: update Procfile to use python3 for main_transfer script
jirhiker Sep 23, 2025
b57864d
feat: update Procfile to use python3 for main_transfer script
jirhiker Sep 23, 2025
96d826d
feat: update main_transfer to use environment variable for transfer l…
jirhiker Sep 23, 2025
e3e67b0
Formatting changes
jirhiker Sep 23, 2025
04c9e81
feat: update main_transfer to use environment variable for transfer l…
jirhiker Sep 23, 2025
d9e7137
Formatting changes
jirhiker Sep 23, 2025
951f0b7
feat: add filtering functions for valid measuring agencies and well d…
jirhiker Sep 24, 2025
6247563
Formatting changes
jirhiker Sep 24, 2025
d0b4a43
feat: update file paths for valid well data sources and measuring age…
jirhiker Sep 24, 2025
dd5b522
Merge branch 'staging' into transfer
jirhiker Sep 24, 2025
ec01432
feat: enhance data transfer process with schema management and file p…
jirhiker Sep 24, 2025
d68edc5
Formatting changes
jirhiker Sep 24, 2025
9c614bd
feat: refactor logging implementation and enhance error handling in t…
jirhiker Sep 24, 2025
be34607
Formatting changes
jirhiker Sep 24, 2025
00369e4
WIP: first draft of thing_id query parameter for /sensor
jacob-a-brown Sep 24, 2025
e66f573
feat: create new Deployment model
ksmuczynski Sep 24, 2025
468fdba
refactor: modify `mapped_column` for `recording_interval` field
ksmuczynski Sep 24, 2025
404968b
feat: add `deployment` relationship and proxy to `Thing` model
ksmuczynski Sep 24, 2025
7ffb16e
feat: add `deployment` relationship and `thing` proxy to the `Sensor`…
ksmuczynski Sep 24, 2025
39645fa
refactor: import necessary classes to `Sensor` model so they can be f…
ksmuczynski Sep 24, 2025
290e66f
refactor: update foreign key names in `Deployment` table
ksmuczynski Sep 24, 2025
691eecf
feat: add `deployment` model to `__init__` file so mappers can be con…
ksmuczynski Sep 24, 2025
a4e9e93
refactor: update proxy name in `Thing` table from `sensor` to `sensors`.
ksmuczynski Sep 24, 2025
a986d96
fix: fix thing_id query parameter for /sensor
jacob-a-brown Sep 24, 2025
978c057
refactor: remove print debugging statement
jacob-a-brown Sep 24, 2025
351dd45
feat: enhance asset transfer logging and integrate asset transfer in …
jirhiker Sep 24, 2025
21ce2e8
Formatting changes
jirhiker Sep 24, 2025
4e1fcb4
feat: enhance asset transfer process with well photo integration and …
jirhiker Sep 25, 2025
f56831c
Formatting changes
jirhiker Sep 25, 2025
bd98268
feat: add warning for missing photos during asset transfer process
jirhiker Sep 25, 2025
c258c96
Formatting changes
jirhiker Sep 25, 2025
9aa4092
feat: add warning for missing photos during asset transfer process
jirhiker Sep 25, 2025
dfb723a
Merge branch 'staging' into transfer
jirhiker Sep 25, 2025
53321ef
chore: ignore transfer branch in code format workflow
jirhiker Sep 25, 2025
6a446fa
feat: update uv.lock
jirhiker Sep 25, 2025
0ae9c46
fix: correct datetime formatting for TimeMeasured in waterlevels_tran…
jirhiker Sep 25, 2025
979ad23
fix: elevate logging level to critical for location and well creation…
jirhiker Sep 25, 2025
9fa5603
fix: improve datetime formatting for TimeMeasured in waterlevels_tran…
jirhiker Sep 25, 2025
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
2 changes: 2 additions & 0 deletions .github/workflows/format_code.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Code Format
on:
push:
branches-ignore:
- transfer
permissions:
contents: read
jobs:
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: gunicorn -b :8080 transfers.entrypoint:app -k uvicorn.workers.UvicornWorker
web: python3 -m transfers.transfer
2 changes: 1 addition & 1 deletion core/initializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def init_hypertables():
# session.close()


def init_lexicon(path=None):
def init_lexicon(path: str = None) -> None:
if path is None:
path = Path(__file__).parent / "lexicon.json"

Expand Down
4 changes: 1 addition & 3 deletions db/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
class Location(Base, AutoBaseMixin, ReleaseMixin):
__versioned__ = {}

nma_pk_location: Mapped[UUID] = mapped_column(
String(36), nullable=True, unique=True
)
nma_pk_location: Mapped[UUID] = mapped_column(String(36), nullable=True)
description: Mapped[str] = mapped_column
# name: Mapped[str] = mapped_column(String(255), nullable=True)
point: Mapped[WKBElement] = mapped_column(
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ dependencies = [
"multidict==6.6.3",
"numpy==2.3.2",
"packaging==25.0",
"pact-python>=2.3.3",
"pandas==2.3.2",
"pandas-stubs==2.3.0.250703",
"pg8000==1.31.4",
Expand Down
4 changes: 2 additions & 2 deletions services/lexicon_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def add_lexicon_term(
)
audit_add(user, category)
session.add(category)
session.commit()
session.flush()
# session.commit()
# session.flush()

db_categories.append(category)

Expand Down
32 changes: 23 additions & 9 deletions transfers/asset_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
get_storage_bucket,
get_storage_client,
)
from transfers.util import get_valid_things, logger
from transfers.util import get_valid_things, read_csv
from transfers.logger import logger


def transfer_assets(session: Session) -> None:
Expand All @@ -41,21 +42,34 @@ def transfer_assets(session: Session) -> None:
bucket = get_storage_bucket(client)
logger.info(f"Using bucket {bucket.name}")

well_photos = read_csv("WellPhotos")
# for name in ['AR0001']: # for testing
for thing in get_valid_things(session):
name = thing.name
# find images in temp bucket
logger.info(f"Processing PointID: {thing.name}")
blobs = bucket.list_blobs(prefix=f"nma-photos/{thing.name}")
# move blobs from temp to assets bucket
for srcblob in blobs:
f = srcblob.download_as_bytes()
head, filename = srcblob.name.split("/")
photos = well_photos[well_photos["PointID"] == thing.name]
if photos.empty:
photos = well_photos[well_photos["PointID"] == thing.name.replace("-", "")]
if photos.empty:
logger.info(f"No photos found for PointID: {thing.name}")
continue

for i, row in enumerate(photos.itertuples()):
photo_path = row.OLEPath
srcblob = bucket.get_blob(f"nma-photos/{photo_path}")
if not srcblob:
logger.critical(
f"No photo found for PointID: {thing.name}, {photo_path}"
)
continue

head, filename = srcblob.name.split("/")
f = srcblob.download_as_bytes()
ff = UploadFile(file=io.BytesIO(f), filename=filename, size=len(f))

uri, blob_name = gcs_upload(ff, bucket)
add_asset(session, ff, filename, thing.id, uri, blob_name)
logger.info(
f"Added asset thing.id={thing.id} thing={thing.name} uri: {uri}"
)


def transfer_assets_testing(session: Session) -> None:
Expand Down
16 changes: 8 additions & 8 deletions transfers/contact_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# ===============================================================================
import numpy as np
import pandas as pd
from transfers.util import read_csv, filter_to_valid_point_ids, logger, replace_nans
from transfers.util import read_csv, filter_to_valid_point_ids, replace_nans
from transfers.logger import logger
from db import Thing, Contact, ThingContactAssociation, Email, Phone, Address

from schemas.contact import CreateContact, CreateAddress


Expand Down Expand Up @@ -58,9 +58,9 @@ def transfer_contacts(session):
odf = filter_to_valid_point_ids(session, odf)
for i, row in odf.iterrows():
thing = session.query(Thing).where(Thing.name == row.PointID).first()
print(f"Processing PointID: {i} {row.PointID}")
logger.info(f"Processing PointID: {i} {row.PointID}")
if thing is None:
logger.warning(
logger.critical(
f"Thing with PointID {row.PointID} not found. Skipping owner."
)
continue
Expand All @@ -71,7 +71,7 @@ def transfer_contacts(session):
session.flush()
logger.info(f"added first contact for PointID {row.PointID}")
except Exception as e:
logger.warning(
logger.critical(
f"Skipping first contact for PointID {row.PointID} due to validation error: {e}"
)
from pprint import pprint
Expand All @@ -83,9 +83,9 @@ def transfer_contacts(session):
add_second_contact(session, row, thing)
session.commit()
session.flush()
print(f"added second contact for PointID {row.PointID}")
logger.info(f"added second contact for PointID {row.PointID}")
except Exception as e:
print(
logger.critical(
f"Skipping second contact for PointID {row.PointID} due to validation error: {e}"
)
session.rollback()
Expand Down Expand Up @@ -178,7 +178,7 @@ def add_first_contact(session, row, thing):
CreateAddress.model_validate(address_data)
contact.addresses.append(Address(**address_data))
except Exception as e:
logger.warning(
logger.critical(
f"Skipping physical address for first contact {name}. Validation error: {e}"
)

Expand Down
19 changes: 19 additions & 0 deletions transfers/data/valid_measuring_agency.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"MeasuringAgency","valid"
"Bayard",NO
"Bernalillo Cty",NO
"BLM",NO
"NESWCD",NO
"NMBGMR",Yes
"NMED",NO
"NMISC",NO
"NMOSE",NO
"NMT","Yes"
"NPS",Yes
"OSWCD",NO
"PVACD",NO
"SFC",NO
"SNL",Yes
"TSWCD",Yes
"TWDB",NO
"USFS",Yes
"USGS",NO
Loading