Skip to content

Commit

Permalink
publish ingest json schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
fvankrieken committed Oct 16, 2024
1 parent 7159e38 commit d56695e
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,55 @@
from dcpy.utils import s3
from dcpy.models.product import metadata as product_metadata
from dcpy.models.product.dataset import metadata_v2 as dataset_metadata
from dcpy.models.lifecycle import ingest as ingest_models

import json
from tempfile import TemporaryDirectory
from pathlib import Path

RECIPES_BUCKET = "edm-recipes"
PUBLISHING_BUCKET = "edm-publishing"
DO_SCHEMA_FOLDER = "data-engineering-devops/schemas/"

schemas = [
{
"name": "org_metadata.schema.json",
"bucket": PUBLISHING_BUCKET,
"folder": "product/",
"schema": product_metadata.OrgMetadataFile.model_json_schema(),
},
{
"name": "product_metadata.schema.json",
"bucket": PUBLISHING_BUCKET,
"folder": "product/",
"schema": product_metadata.ProductMetadataFile.model_json_schema(),
},
{
"name": "dataset_metadata.schema.json",
"bucket": PUBLISHING_BUCKET,
"folder": "product/dataset/",
"schema": dataset_metadata.Metadata.model_json_schema(),
},
{
"name": "template.json",
"bucket": RECIPES_BUCKET,
"folder": "ingest/",
"schema": ingest_models.Template.model_json_schema(),
},
{
"name": "config.json",
"bucket": RECIPES_BUCKET,
"folder": "ingest/",
"schema": ingest_models.Config.model_json_schema(),
},
]

for schema in schemas:
with TemporaryDirectory() as _dir:
p = Path(_dir) / schema["name"]
open(p, "w").write(json.dumps(schema["schema"]))
s3.upload_file(
bucket="edm-publishing",
bucket=schema["bucket"],
path=p,
key=DO_SCHEMA_FOLDER + schema["folder"] + schema["name"],
acl="public-read",
Expand Down

0 comments on commit d56695e

Please sign in to comment.