Skip to content

Commit

Permalink
Merge pull request #481 from datalad/abcdj-aliaschange
Browse files Browse the repository at this point in the history
Alias generation bug fix
  • Loading branch information
jsheunis authored Jul 22, 2024
2 parents a98b5ca + cd366cf commit c0ed29f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tools/create_alias_concept_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

def add_aliases(alias_path, catalog):
alias_path = Path(alias_path)
ids_processed = []
with alias_path.open(newline="") as tsvfile:
reader = csv.DictReader(tsvfile, delimiter="\t")
for i, row in enumerate(reader):
Expand All @@ -35,14 +36,19 @@ def add_aliases(alias_path, catalog):
catalog=catalog,
metadata=json.dumps(meta_item),
)
ids_processed.append(row["dataset_id"])

return ids_processed

def create_metadata_files(catalog):

def create_metadata_files(catalog, ids_to_process):
# Get report
report = catalog.get_catalog_report()
# Write metadata for all datasets
# - assumes that datasets have aliases set
for d in report.get("datasets", []):
if d not in ids_to_process:
continue
# Get latest version
current_ds_versions = [
dsv for dsv in report.get("versions") if dsv["dataset_id"] == d
Expand Down Expand Up @@ -98,7 +104,8 @@ def create_metadata_files(catalog):
catalog = EnsureWebCatalog()(args.catalog)

# If aliases are provided, first set them in metadata
ids_processed = []
if args.aliases:
add_aliases(args.aliases, catalog)
ids_processed = add_aliases(args.aliases, catalog)

create_metadata_files(catalog)
create_metadata_files(catalog, ids_processed)

0 comments on commit c0ed29f

Please sign in to comment.