Skip to content

Commit a68d3aa

Browse files
committed
Merge branch 'main' of github.com:UW-Macrostrat/macrostrat
2 parents 126d3da + 6b5301d commit a68d3aa

File tree

3 files changed

+42
-19
lines changed

3 files changed

+42
-19
lines changed

py-modules/map-integration/macrostrat/map_integration/__init__.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
from macrostrat.core import app
1616
from macrostrat.database import Database
1717
from macrostrat.map_integration.commands.prepare_fields import _prepare_fields
18-
#from macrostrat.map_integration.pipeline import ingest_map
18+
19+
# from macrostrat.map_integration.pipeline import ingest_map
1920
from macrostrat.map_integration.process.geometry import create_rgeom, create_webgeom
2021
from macrostrat.map_integration.utils.ingestion_utils import (
2122
find_gis_files,
@@ -145,7 +146,6 @@ def delete_sources(
145146
dict(slug=s),
146147
).scalar()
147148

148-
149149
# Delete ALL ingest-related rows for this source
150150
db.run_sql(
151151
"""
@@ -409,7 +409,12 @@ def staging(
409409

410410

411411
@staging_cli.command("s3-upload")
412-
def cmd_upload_dir(slug: str = ..., data_path: Path = ..., ext: str = Option(".gdb", help="extension of the data path"), ingest_process_id: int = Option(None)):
412+
def cmd_upload_dir(
413+
slug: str = ...,
414+
data_path: Path = ...,
415+
ext: str = Option(".gdb", help="extension of the data path"),
416+
ingest_process_id: int = Option(None),
417+
):
413418
"""Upload a local directory to the staging bucket under SLUG/."""
414419
db = get_database()
415420
source_id = db.run_query(
@@ -525,6 +530,7 @@ def list_layers(e00_path: Path) -> set[str]:
525530
def run(cmd):
526531
p = subprocess.run(cmd, capture_output=True, text=True)
527532
return p.returncode, p.stdout, p.stderr
533+
528534
created = False
529535
for f in e00_files:
530536
base = f.stem
@@ -542,9 +548,13 @@ def run(cmd):
542548
# create/overwrite first successful write
543549
cmd += ["-overwrite"]
544550
cmd += [
545-
str(out_gpkg), str(f), lyr,
546-
"-nln", f"{base}_lines",
547-
"-nlt", "LINESTRING",
551+
str(out_gpkg),
552+
str(f),
553+
lyr,
554+
"-nln",
555+
f"{base}_lines",
556+
"-nlt",
557+
"LINESTRING",
548558
]
549559
rc, _, err = run(cmd)
550560
if rc == 0:
@@ -557,9 +567,13 @@ def run(cmd):
557567
else:
558568
cmd = ["ogr2ogr", "-f", "GPKG", "-update", "-append"]
559569
cmd += [
560-
str(out_gpkg), str(f), lyr,
561-
"-nln", f"{base}_points",
562-
"-nlt", "POINT",
570+
str(out_gpkg),
571+
str(f),
572+
lyr,
573+
"-nln",
574+
f"{base}_points",
575+
"-nlt",
576+
"POINT",
563577
]
564578
rc, _, _ = run(cmd)
565579
if rc == 0:
@@ -572,9 +586,13 @@ def run(cmd):
572586
else:
573587
cmd = ["ogr2ogr", "-f", "GPKG", "-update", "-append"]
574588
cmd += [
575-
str(out_gpkg), str(f), lyr,
576-
"-nln", f"{base}_polygons",
577-
"-nlt", "POLYGON",
589+
str(out_gpkg),
590+
str(f),
591+
lyr,
592+
"-nln",
593+
f"{base}_polygons",
594+
"-nlt",
595+
"POLYGON",
578596
]
579597
rc, _, _ = run(cmd)
580598
if rc == 0:
@@ -584,6 +602,7 @@ def run(cmd):
584602

585603
print(f"Done: {out_gpkg}")
586604

605+
587606
# ----------------------------------------------------------------------------------------------------------------------
588607

589608

@@ -715,10 +734,8 @@ def staging_bulk(
715734
),
716735
)
717736

718-
719737
cmd_upload_dir(slug=slug, data_path=region_path, ext=ext)
720738

721-
722739
map_info = get_map_info(db, slug)
723740
_prepare_fields(map_info)
724741
create_rgeom(map_info)
@@ -730,4 +747,4 @@ def staging_bulk(
730747
slug_list_path = parent / f"staged_slugs.txt"
731748
with open(slug_list_path, "w") as file:
732749
for slug in staged_slugs:
733-
file.write(slug + "\n")
750+
file.write(slug + "\n")

py-modules/map-integration/macrostrat/map_integration/commands/ingest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ def merge_metadata_polygons(polygon_df, meta_df, join_col) -> G.GeoDataFrame:
4545

4646

4747
def preprocess_dataframe(
48-
poly_line_pt_df: G.GeoDataFrame, meta_path: Path, join_col: str, feature_suffix: str, pipeline: str
48+
poly_line_pt_df: G.GeoDataFrame,
49+
meta_path: Path,
50+
join_col: str,
51+
feature_suffix: str,
52+
pipeline: str,
4953
) -> Tuple[G.GeoDataFrame, str, str, str]:
5054
"""
5155
Preprocess a GeoDataFrame by merging in metadata from a local .tsv,
@@ -291,7 +295,7 @@ def ingest_map(
291295
meta_path=meta_path,
292296
join_col=join_col.lower(),
293297
feature_suffix=feature_suffix,
294-
pipeline=pipeline
298+
pipeline=pipeline,
295299
)
296300
if feature_suffix == "polygons":
297301
ingest_results["ingest_pipeline"] = ingest_pipeline

py-modules/map-integration/macrostrat/map_integration/utils/ingestion_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ def get_strat_names_df() -> pd.DataFrame:
107107

108108

109109
# standard map age function. User gets to input their column 1 and a column 2 data to map to our ages.
110-
def map_t_b_standard(meta_df: G.GeoDataFrame, col_one: str, col_two: str) -> G.GeoDataFrame:
110+
def map_t_b_standard(
111+
meta_df: G.GeoDataFrame, col_one: str, col_two: str
112+
) -> G.GeoDataFrame:
111113
interval_df = get_age_interval_df().reset_index(drop=True)
112114
interval_lookup = {
113115
str(row["interval_name"]).strip().lower(): int(row["id"])
@@ -132,7 +134,7 @@ def map_t_b_standard(meta_df: G.GeoDataFrame, col_one: str, col_two: str) -> G.G
132134
meta_df["b_interval"] = mapped_col_one
133135
meta_df["t_interval"] = mapped_col_one
134136

135-
#fallback to map col_two if col_one row is empty
137+
# fallback to map col_two if col_one row is empty
136138
if col_two in meta_df.columns:
137139
needs_fill = meta_df["b_interval"].isna() | meta_df["t_interval"].isna()
138140
if needs_fill.any():

0 commit comments

Comments
 (0)