Skip to content

Commit 8f2e10d

Browse files
authored
Merge pull request #104 from apdavison/rename-scope
Rename "scope" to "release_status"
2 parents 15ce3c1 + d456a1e commit 8f2e10d

File tree

238 files changed

+728
-613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+728
-613
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,28 +80,28 @@ Using these classes, it is possible to list all metadata matching a particular c
8080
```
8181

8282
```
83-
>>> datasets = DatasetVersion.list(client, techniques=whole_cell_patch, scope="in progress")
83+
>>> datasets = DatasetVersion.list(client, techniques=whole_cell_patch, release_status="in progress")
8484
```
8585

8686
For research products that are versioned, such as datasets, models, and software, certain attributes may be inherited from the parent (e.g. a DatasetVersion generally inherits its name from a Dataset). In this case, we have a convenience method to retrieve the parent's name:
8787

8888
```
89-
>>> print(datasets[0].get_name(client, scope="in progress"))
89+
>>> print(datasets[0].get_name(client, release_status="in progress"))
9090
'Cholinergic interneurons in the striatum - Single cell patch clamp recordings'
9191
```
9292

9393
If you know the unique identifier of an object, you can retrieve it directly:
9494

9595
```
96-
>>> dataset = DatasetVersion.from_id("17196b79-04db-4ea4-bb69-d20aab6f1d62", client, scope="in progress")
96+
>>> dataset = DatasetVersion.from_id("17196b79-04db-4ea4-bb69-d20aab6f1d62", client, release_status="in progress")
9797
```
9898

9999
Links between metadata in the Knowledge Graph are not followed automatically,
100100
to avoid unnecessary network traffic, but can be followed with the `resolve()` method:
101101

102102
```
103-
>>> license = dataset.license.resolve(client, scope="in progress")
104-
>>> authors = [author.resolve(client, scope="in progress") for author in dataset.authors]
103+
>>> license = dataset.license.resolve(client, release_status="in progress")
104+
>>> authors = [author.resolve(client, release_status="in progress") for author in dataset.authors]
105105
```
106106

107107
The associated metadata is accessible as attributes of the Python objects, e.g.:

builder/additional_methods/DatasetVersion.py.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
def download(self, local_path, client, accept_terms_of_use=False):
22
if accepted_terms_of_use(client, accept_terms_of_use=accept_terms_of_use):
3-
repo = self.repository.resolve(client, scope=self.scope or None)
3+
repo = self.repository.resolve(client, release_status=self.release_status or None)
44
if (repo.iri.value.startswith("https://object.cscs.ch/v1/AUTH")
55
or repo.iri.value.startswith("https://data-proxy.ebrains.eu/api/v1/public")
66
):

builder/additional_methods/Person.py.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def me(cls, client, allow_multiple=False, follow_links=None):
77
user_info = client.user_info()
88
possible_matches = cls.list(
9-
client, scope="in progress", space="common",
9+
client, release_status="in progress", space="common",
1010
follow_links=follow_links,
1111
family_name=user_info.family_name,
1212
given_name=user_info.given_name

builder/additional_methods/ScholarlyArticle.py.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def get_journal(self, client, with_volume=False, with_issue=False):
22
journal = volume = issue = None
33
if self.is_part_of:
4-
issue_or_volume = self.is_part_of.resolve(client, scope=self.scope, follow_links={"is_part_of": {}})
4+
issue_or_volume = self.is_part_of.resolve(client, release_status=self.release_status, follow_links={"is_part_of": {}})
55
if isinstance(issue_or_volume, PublicationIssue):
66
volume = issue_or_volume.is_part_of
77
issue = issue_or_volume

builder/fairgraph_module_template.py.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ class {{ class_name }}({{base_class}}, OM{{ class_name }}):
4646
existence_query_properties = {{ existence_query_properties }}
4747
{%- endif %}
4848

49-
def __init__(self {%- for arg in constructor_arguments -%}, {{arg}}=None{%- endfor -%}, id=None, data=None, space=None, scope=None):
49+
def __init__(self {%- for arg in constructor_arguments -%}, {{arg}}=None{%- endfor -%}, id=None, data=None, space=None, release_status=None):
5050
return {{ base_class }}.__init__(self, {{ standard_init_properties }}data=data {%- for arg in constructor_arguments -%}, {{arg}}={{arg}}{%- endfor -%})
5151
{{ additional_methods }}

builder/update_openminds.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,14 @@
1313

1414
OPENMINDS_VERSION = "latest"
1515

16-
name_map = {
17-
"scope": "model_scope", # this is because 'scope' is already a keyword
18-
# we could rename the 'scope' keyword to 'stage'
19-
# but we would have the same problem, as there is
20-
# a property named 'stage'
21-
# Suggested resolution: rename the property "scope" in openMINDS to "hasScope"
22-
}
2316

2417
global_aliases = {
2518
"short_name": "alias",
2619
"full_name": "name",
2720
"has_versions": "versions",
2821
"has_entity": "entities",
29-
"hashes": "hash"
22+
"hashes": "hash",
23+
"scope": "model_scope"
3024
}
3125

3226

@@ -235,20 +229,17 @@
235229
}
236230

237231
def generate_python_name(json_name):
238-
if json_name in name_map:
239-
python_name = name_map[json_name]
240-
else:
241-
python_name = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", json_name.strip())
242-
python_name = re.sub("([a-z0-9])([A-Z])", r"\1_\2", python_name).lower()
243-
replacements = [
244-
("-", "_"), (".", "_"), ("+", "plus"), ("#", "sharp"), (",", "comma"), ("(", ""), (")", "")
245-
]
246-
for before, after in replacements:
247-
python_name = python_name.replace(before, after)
248-
if python_name[0] in number_names: # Python variables can't start with a number
249-
python_name = number_names[python_name[0]] + python_name[1:]
250-
if not python_name.isidentifier():
251-
raise NameError(f"Cannot generate a valid Python name from '{json_name}'")
232+
python_name = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", json_name.strip())
233+
python_name = re.sub("([a-z0-9])([A-Z])", r"\1_\2", python_name).lower()
234+
replacements = [
235+
("-", "_"), (".", "_"), ("+", "plus"), ("#", "sharp"), (",", "comma"), ("(", ""), (")", "")
236+
]
237+
for before, after in replacements:
238+
python_name = python_name.replace(before, after)
239+
if python_name[0] in number_names: # Python variables can't start with a number
240+
python_name = number_names[python_name[0]] + python_name[1:]
241+
if not python_name.isidentifier():
242+
raise NameError(f"Cannot generate a valid Python name from '{json_name}'")
252243
return python_name
253244

254245

@@ -665,7 +656,7 @@ def get_type(prop):
665656
else:
666657
base_class = "KGObject"
667658
default_space = get_default_space(module_name, class_name)
668-
standard_init_properties = "id=id, space=space, scope=scope, "
659+
standard_init_properties = "id=id, space=space, release_status=release_status, "
669660
properties = []
670661
plurals_special_cases = {
671662
# because this is a single item (PropertyValueList), but that item contains a list

fairgraph/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Resolvable: # all
5656
def resolve(
5757
self,
5858
client: KGClient,
59-
scope: Optional[str] = None,
59+
release_status: Optional[str] = None,
6060
use_cache: bool = True,
6161
follow_links: Optional[Dict[str, Any]] = None,
6262
):

0 commit comments

Comments
 (0)