Skip to content

Commit 762d535

Browse files
authored
Merge pull request #455 from DataIntegrationGroup/BDMS-520-1-1-Cleanup-2.0
feat: refactor transfer_all function and add transferable_wells utility
2 parents 75156b7 + 8163ade commit 762d535

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

transfers/transfer.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def _drop_and_rebuild_db() -> None:
281281

282282

283283
@timeit
284-
def transfer_all(metrics, limit=100, profile_waterlevels: bool = True):
284+
def transfer_all(metrics: Metrics) -> list[ProfileArtifact]:
285285
message("STARTING TRANSFER", new_line_at_top=False)
286286
if get_bool_env("DROP_AND_REBUILD_DB", False):
287287
logger.info("Dropping schema and rebuilding database from migrations")
@@ -300,7 +300,7 @@ def transfer_all(metrics, limit=100, profile_waterlevels: bool = True):
300300
for field in transfer_options.__dataclass_fields__
301301
},
302302
)
303-
303+
limit = int(os.getenv("TRANSFER_LIMIT", 1000))
304304
flags = {"TRANSFER_ALL_WELLS": True, "LIMIT": limit}
305305
message("TRANSFER_FLAGS")
306306
logger.info(flags)
@@ -313,9 +313,7 @@ def transfer_all(metrics, limit=100, profile_waterlevels: bool = True):
313313
# =========================================================================
314314
if continuous_water_levels_only:
315315
logger.info("CONTINUOUS_WATER_LEVELS set; running only continuous transfers")
316-
_run_continuous_water_level_transfers(
317-
metrics, flags, profile_waterlevels, profile_artifacts
318-
)
316+
_run_continuous_water_level_transfers(metrics, flags)
319317
return profile_artifacts
320318
else:
321319
message("PHASE 1: FOUNDATIONAL TRANSFERS (PARALLEL)")
@@ -631,13 +629,9 @@ def main():
631629
"Set POSTGRES_DB=ocotilloapi_dev in .env file"
632630
)
633631

634-
limit = int(os.getenv("TRANSFER_LIMIT", 1000))
635-
profile_waterlevels = get_bool_env("PROFILE_WATERLEVELS_CONTINUOUS", True)
636632
metrics = Metrics()
637633

638-
profile_artifacts = transfer_all(
639-
metrics, limit=limit, profile_waterlevels=profile_waterlevels
640-
)
634+
profile_artifacts = transfer_all(metrics)
641635

642636
if get_bool_env("CLEANUP_LOCATIONS", True):
643637
message("CLEANING UP LOCATIONS")

transfers/transferable_wells.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# ===============================================================================
2+
# Copyright 2026 ross
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# ===============================================================================
16+
from transfers.util import read_csv, get_transferable_wells
17+
18+
19+
def main():
20+
df = read_csv("WellData", dtype={"OSEWelltagID": str})
21+
df = get_transferable_wells(df)
22+
df = df[["PointID", "DataSource"]]
23+
df.to_csv("transferable_wells.csv", index=False, float_format="%.2f")
24+
25+
26+
if __name__ == "__main__":
27+
main()
28+
# ============= EOF =============================================

0 commit comments

Comments
 (0)