-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
54 lines (46 loc) · 1.8 KB
/
Copy pathutils.py
File metadata and controls
54 lines (46 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Helper functions for Federated Learning RO-Crate creation
from datetime import datetime
import os
import uuid
import requests
from rocrate.model import ContextEntity, Person
from rocrate.rocrate import ROCrate
from rocrate_validator import services, models
#####################
# crate validation #
#####################
def validate_crate(
crate_uri,
profile_identifier: "ro-crate-1.1",
requirement_severity=models.Severity.REQUIRED,
**kwargs,
):
# Create an instance of `ValidationSettings` class to configure the validation
settings = services.ValidationSettings(
# Set the path to the RO-Crate root directory
rocrate_uri=crate_uri,
# Set the identifier of the RO-Crate profile to use for validation.
# If not set, the system will attempt to automatically determine the appropriate validation profile.
profile_identifier=profile_identifier,
# Set the requirement level for the validation
requirement_severity=requirement_severity,
# requirement_severity=models.Severity.RECOMMENDED, # use for best practices!
**kwargs,
)
# Call the validation service with the settings
result = services.validate(settings)
# Check if the validation was successful
if not result.has_issues():
print("RO-Crate is valid!")
else:
print("RO-Crate is invalid!")
# Explore the issues
for issue in result.get_issues():
# Every issue object has a reference to the check that failed, the severity of the issue, and a message describing the issue.
print(
f'Detected issue of severity {issue.severity.name} with check "{issue.check.identifier}": {issue.message}'
)
####################
# helper functions #
####################
# add helper functions here