Skip to content

Commit 8dd1423

Browse files
EliEli
authored andcommitted
Allow dropbox to work off a config variable (first case is daily_dropbox_spec)
1 parent c95c7f7 commit 8dd1423

3 files changed

Lines changed: 50 additions & 5 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
data:
3+
- name: daily
4+
collect:
5+
file_pattern: "{source}_{station_id}_{agency_id}_{param}_{syear}_{eyear}.csv"
6+
location: "//cnrastore-bdo/Modeling_Data/repo_staging_auto/daily/raw"
7+
recursive_search: false
8+
reader: read_ts
9+
selector: value
10+
11+
metadata:
12+
station_id: infer_from_filename
13+
source: infer_from_filename
14+
agency_id: infer_from_filename
15+
agency: registry_lookup
16+
param: infer_from_filename
17+
subloc: default
18+
unit: ft^3/s
19+
freq: D
20+
time_zone: Etc/GMT+8
21+
latitude: registry_lookup
22+
longitude: registry_lookup
23+
projection_x_coordinate: registry_lookup
24+
projection_y_coordinate: registry_lookup
25+
26+
output:
27+
repo_name: daily_formatted
28+
staging:
29+
dir: staging
30+
float_format: "%0.3f"
31+
chunk_years: False
32+
reconcile:
33+
#repo_data_dir: ./fake_repo
34+
prefer: staged
35+
allow_new_series: true
36+
inspection:
37+
recent_years: 3
38+
p3: 0.15
39+
p10: 0.05

dms_datastore/config_data/dstore_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sublocations: station_subloc.csv
55
ncro_inventory: ncro_inventory_full.csv
66

77
daily_data_manifest: daily_data_manifest.csv
8-
8+
daily_dropbox_spec: daily_dropbox.yaml
99

1010
file_deletion_list: non_15_min_files_checked.txt
1111
compare_excepts_formatted: compare_excepts_formatted.txt

dms_datastore/dropbox_data.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
import yaml
55
import glob
66
import click
7+
import dms_datastore.dstore_config
78
from vtools import dst_st, ts_merge, ts_splice,ts_coarsen
89
from omegaconf import OmegaConf
910
from vtools.data.indexing import infer_freq_robust
1011
from dms_datastore.read_ts import read_ts, infer_freq_robust
1112
from dms_datastore.write_ts import write_ts_csv
12-
from dms_datastore.dstore_config import repo_registry, repo_config
13+
from dms_datastore.dstore_config import repo_registry, repo_config, config_file
1314
from dms_datastore.filename import interpret_fname, meta_to_filename, naming_spec
1415
from dms_datastore.reconcile_data import update_repo
1516
import logging
@@ -419,7 +420,7 @@ def _require_lower(name):
419420
)
420421

421422

422-
def get_data(spec, selected_names=None):
423+
def apply_dropbox_workflow(spec, selected_names=None):
423424
logger.info("dropbox: loaded %d recipe entries", len(spec["data"]))
424425
always_skip = True
425426

@@ -750,16 +751,21 @@ def get_data(spec, selected_names=None):
750751
)
751752

752753
def dropbox_data(spec_fname, selected_names=None):
754+
spec_fname = (
755+
spec_fname
756+
if os.path.exists(spec_fname)
757+
else config_file(spec_fname)
758+
)
753759
spec = get_spec(spec_fname)
754-
get_data(spec, selected_names=selected_names)
760+
apply_dropbox_workflow(spec, selected_names=selected_names)
755761

756762

757763
@click.command(name="dropbox")
758764
@click.option(
759765
"--input",
760766
"spec_fname",
761767
required=True,
762-
type=click.Path(exists=True, dir_okay=False, readable=True),
768+
type=str,
763769
help="YAML file with dropbox specification.",)
764770
@click.option(
765771
"--name",

0 commit comments

Comments
 (0)