-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update data directory structure (#22)
- Loading branch information
1 parent
2dd4eff
commit 36bcd72
Showing
7 changed files
with
46 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Whether to run data-processing tasks locally | ||
# or on the cloud with Coiled. | ||
local: true | ||
# Output location for data files. Can be a local directory | ||
# or a remote path like "s3://path/to/bucket". | ||
data-dir: ./data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,33 @@ | ||
import boto3 | ||
import fsspec | ||
import yaml | ||
from filelock import FileLock | ||
from upath import UPath as Path | ||
|
||
LOCAL = True | ||
# LOCAL = False | ||
with open(Path(__file__).parent / "config.yml", "rb") as f: | ||
data = yaml.safe_load(f) | ||
|
||
LOCAL = data["local"] | ||
ROOT = Path(data["data-dir"]).resolve() | ||
fs = fsspec.filesystem(ROOT.protocol, use_listings_cache=False) | ||
|
||
if LOCAL: | ||
ROOT = Path(__file__).parent.parent.resolve() / "data" | ||
fs = fsspec.filesystem("local") | ||
REGION = None | ||
storage_options = {} | ||
else: | ||
# TODO: Make the cloud path nicer (e.g. s3://coiled-datasets-rp) | ||
ROOT = Path("s3://openscapes-scratch/jrbourbeau/etl-tpch/data") | ||
fs = fsspec.filesystem("s3", use_listings_cache=False) | ||
# Find cloud region being used | ||
bucket = str(ROOT).replace("s3://", "").split("/")[0] | ||
resp = boto3.client("s3").get_bucket_location(Bucket=bucket) | ||
REGION = resp["LocationConstraint"] or "us-east-1" | ||
storage_options = {"AWS_REGION": REGION, "AWS_S3_ALLOW_UNSAFE_RENAME": "true"} | ||
|
||
STAGING_JSON_DIR = ROOT / "staged" / "json" | ||
STAGING_PARQUET_DIR = ROOT / "staged" / "parquet" | ||
RAW_JSON_DIR = ROOT / "raw" / "json" | ||
RAW_PARQUET_DIR = ROOT / "raw" / "parquet" | ||
PROCESSED_DATA_DIR = ROOT / "processed" | ||
REDUCED_DATA_DIR = ROOT / "reduced" | ||
STAGING_DIR = ROOT / "staging" # Input JSON files | ||
PROCESSED_DIR = ROOT / "processed" # Processed Parquet files | ||
RESULTS_DIR = ROOT / "results" # Reduced/aggrgated results | ||
ARCHIVE_DIR = ROOT / "archive" # Archived JSON files | ||
MODEL_FILE = ROOT.parent / "model.json" | ||
MODEL_SERVER_FILE = ROOT.parent / "serve_model.py" | ||
|
||
lock_generate = FileLock("generate.lock") | ||
lock_json_to_parquet = FileLock("json_to_parquet.lock") | ||
lock_compact = FileLock("compact.lock") | ||
lock_dir = Path(__file__).parent.parent / ".locks" | ||
lock_generate = FileLock(lock_dir / "generate.lock") | ||
lock_json_to_parquet = FileLock(lock_dir / "json.lock") | ||
lock_compact = FileLock(lock_dir / "compact.lock") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters