Skip to content

Commit beed407

Browse files
authored
Merge pull request #51 from fairscape/Add-PROV-Roll-Up-Terms
Add prov roll up terms
2 parents 2ca6c62 + 32c2633 commit beed407

13 files changed

Lines changed: 235 additions & 25 deletions

File tree

src/fairscape_cli/commands/build_commands.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from fairscape_cli.models import (
2020
GenerateROCrate,
2121
LinkSubcrates,
22-
collect_subcrate_metadata
22+
collect_subcrate_metadata,
23+
collect_subcrate_aggregated_metrics
2324
)
2425

2526
from fairscape_models.rocrate import ROCrateV1_2
@@ -182,6 +183,9 @@ def build_release(
182183
if keyword not in combined_keywords:
183184
combined_keywords.append(keyword)
184185

186+
# Collect aggregated metrics for AI-Ready scoring
187+
aggregated_metrics = collect_subcrate_aggregated_metrics(release_directory)
188+
185189
parent_params = {
186190
"guid": guid,
187191
"name": name,
@@ -285,6 +289,17 @@ def build_release(
285289
click.echo(f"ERROR: {e}")
286290
ctx.exit(1)
287291

292+
# Add aggregated metrics as individual properties (following evi: prefix pattern)
293+
parent_params["evi:datasetCount"] = aggregated_metrics.dataset_count
294+
parent_params["evi:computationCount"] = aggregated_metrics.computation_count
295+
parent_params["evi:softwareCount"] = aggregated_metrics.software_count
296+
parent_params["evi:schemaCount"] = aggregated_metrics.schema_count
297+
parent_params["evi:totalContentSizeBytes"] = aggregated_metrics.total_content_size_bytes
298+
parent_params["evi:entitiesWithSummaryStats"] = aggregated_metrics.entities_with_summary_stats
299+
parent_params["evi:entitiesWithChecksums"] = aggregated_metrics.entities_with_checksums
300+
parent_params["evi:totalEntities"] = aggregated_metrics.total_entities
301+
parent_params["evi:formats"] = sorted(list(aggregated_metrics.formats))
302+
288303
try:
289304
click.echo("\n=== Creating release RO-Crate ===")
290305
parent_crate_root_dict = GenerateROCrate(**parent_params)

src/fairscape_cli/commands/import_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def import_figshare(
325325
@import_group.command('dataverse')
326326
@click.argument('dataset-doi', type=str)
327327
@click.option('--server-url', default='https://dataverse.harvard.edu', show_default=True, help='Dataverse server URL.')
328-
@click.option('--token', required=False, type=str, help='Dataverse API token (optional, for restricted datasets).')
328+
@click.option('--token', required=False, type=str, help='Dataverse API token.')
329329
@generic_importer_options
330330
@click.pass_context
331331
def import_dataverse(

src/fairscape_cli/commands/rocrate_commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ def registerModel(
956956
"keywords": list(keywords),
957957
"modelType": model_type,
958958
"framework": framework,
959-
"modelFormat": model_format,
959+
"format": model_format,
960960
"trainingDataset": list(training_dataset),
961961
"generatedBy": generated_by,
962962
"filepath": filepath,
@@ -1099,7 +1099,7 @@ def registerHuggingFaceModel(
10991099
"keywords": list(keywords) if keywords else hf_metadata.get('keywords', []),
11001100
"modelType": model_type or hf_metadata.get('model_type'),
11011101
"framework": framework or hf_metadata.get('framework'),
1102-
"modelFormat": model_format or hf_metadata.get('model_format'),
1102+
"format": model_format or hf_metadata.get('model_format'),
11031103
"trainingDataset": list(training_dataset) if training_dataset else hf_metadata.get('training_datasets', []),
11041104
"filepath": hf_metadata.get('download_url'),
11051105
"url": hf_metadata.get('landing_page_url'),

src/fairscape_cli/data_fetcher/generic_data/research_data.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ def to_rocrate(self, output_dir: str, **kwargs) -> str:
8080
"version": file_info.get("version", "1.0"),
8181
"associatedPublication": self.doi or None,
8282
"additionalDocumentation": None,
83-
"format": file_format,
84-
"schema": "",
83+
"format": file_format,
8584
"derivedFrom": [],
8685
"usedBy": [],
8786
"generatedBy": [],

src/fairscape_cli/models/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88

99
from fairscape_cli.models.computation import Computation, GenerateComputation
1010
from fairscape_cli.models.rocrate import (
11-
ROCrate,
11+
ROCrate,
1212
GenerateROCrate,
13-
ReadROCrateMetadata,
14-
AppendCrate,
13+
ReadROCrateMetadata,
14+
AppendCrate,
1515
CopyToROCrate,
1616
UpdateCrate,
1717
LinkSubcrates,
18-
collect_subcrate_metadata
18+
collect_subcrate_metadata,
19+
collect_subcrate_aggregated_metrics,
20+
AggregatedMetrics
1921
)
2022
from fairscape_cli.models.bagit import BagIt
2123
from fairscape_cli.models.pep import PEPtoROCrateMapper
@@ -39,5 +41,7 @@
3941
'BagIt',
4042
'PEPtoROCrateMapper',
4143
'LinkSubcrates',
42-
'collect_subcrate_metadata'
44+
'collect_subcrate_metadata',
45+
'collect_subcrate_aggregated_metrics',
46+
'AggregatedMetrics'
4347
]

src/fairscape_cli/models/biochem_entity.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def GenerateBioChemEntity(
4040
entityMetadata = {
4141
"@id": guid,
4242
"name": name,
43-
"@type": "https://schema.org/BioChemEntity",
4443
"description": description
4544
}
4645

src/fairscape_cli/models/computation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def GenerateComputation(
3434
computationMetadata = {
3535
"@id": guid,
3636
"name": name,
37-
"@type": "https://w3id.org/EVI#Computation"
3837
}
3938

4039
for key, value in kwargs.items():

src/fairscape_cli/models/dataset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def GenerateDataset(
4141

4242
datasetMetadata = {
4343
"@id": guid,
44-
"name": name,
45-
"@type": "https://w3id.org/EVI#Dataset"
44+
"name": name
4645
}
4746

4847
content_url = None

src/fairscape_cli/models/experiment.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ def GenerateExperiment(
3434

3535
experimentMetadata = {
3636
"@id": guid,
37-
"name": name,
38-
"@type": "https://w3id.org/EVI#Experiment"
37+
"name": name
3938
}
4039

4140
for key, value in kwargs.items():

src/fairscape_cli/models/instrument.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def GenerateInstrument(
4040
instrumentMetadata = {
4141
"@id": guid,
4242
"name": name,
43-
"@type": "https://w3id.org/EVI#Instrument"
4443
}
4544

4645
if filepath and cratePath:

0 commit comments

Comments
 (0)