diff --git a/libraries/client/biomodels_info.py b/libraries/client/biomodels_info.py index 2a67f258..6bb0d446 100644 --- a/libraries/client/biomodels_info.py +++ b/libraries/client/biomodels_info.py @@ -2,20 +2,15 @@ Script to get Biomodels project info """ -import sys import json - -import osb -import operator import pprint +from loadbiomodels import get_model_identifiers, get_model_info verbose = True # verbose = False info_all = {} -from loadbiomodels import get_model_identifiers, get_model_info - if __name__ == "__main__": min_index = 0 diff --git a/libraries/client/cached_info/osb_gh.json b/libraries/client/cached_info/osb_gh.json index 0c3a1e3f..031f910b 100644 --- a/libraries/client/cached_info/osb_gh.json +++ b/libraries/client/cached_info/osb_gh.json @@ -209517,8 +209517,8 @@ "name": "OSBv2", "node_id": "MDEwOlJlcG9zaXRvcnkyNDMzMTY0MTM=", "notifications_url": "https://api.github.com/repos/OpenSourceBrain/OSBv2/notifications{?since,all,participating}", - "open_issues": 130, - "open_issues_count": 130, + "open_issues": 129, + "open_issues_count": 129, "owner": { "avatar_url": "https://avatars.githubusercontent.com/u/1565478?v=4", "events_url": "https://api.github.com/users/OpenSourceBrain/events{/privacy}", @@ -209549,9 +209549,9 @@ }, "private": false, "pulls_url": "https://api.github.com/repos/OpenSourceBrain/OSBv2/pulls{/number}", - "pushed_at": "2025-01-09T14:17:02Z", + "pushed_at": "2025-01-22T10:32:09Z", "releases_url": "https://api.github.com/repos/OpenSourceBrain/OSBv2/releases{/id}", - "size": 47905, + "size": 48835, "ssh_url": "git@github.com:OpenSourceBrain/OSBv2.git", "stargazers_count": 12, "stargazers_url": "https://api.github.com/repos/OpenSourceBrain/OSBv2/stargazers", @@ -211069,8 +211069,8 @@ "name": "SBMLShowcase", "node_id": "MDEwOlJlcG9zaXRvcnk5ODMzNTU3", "notifications_url": "https://api.github.com/repos/OpenSourceBrain/SBMLShowcase/notifications{?since,all,participating}", - "open_issues": 11, - "open_issues_count": 11, + "open_issues": 10, + "open_issues_count": 10, "owner": { "avatar_url": "https://avatars.githubusercontent.com/u/1565478?v=4", "events_url": "https://api.github.com/users/OpenSourceBrain/events{/privacy}", @@ -211101,9 +211101,9 @@ }, "private": false, "pulls_url": "https://api.github.com/repos/OpenSourceBrain/SBMLShowcase/pulls{/number}", - "pushed_at": "2025-01-21T16:15:51Z", + "pushed_at": "2025-01-22T10:44:21Z", "releases_url": "https://api.github.com/repos/OpenSourceBrain/SBMLShowcase/releases{/id}", - "size": 2048, + "size": 2049, "ssh_url": "git@github.com:OpenSourceBrain/SBMLShowcase.git", "stargazers_count": 1, "stargazers_url": "https://api.github.com/repos/OpenSourceBrain/SBMLShowcase/stargazers", diff --git a/libraries/client/info_all.sh b/libraries/client/info_all.sh index 0957a313..07d315ce 100755 --- a/libraries/client/info_all.sh +++ b/libraries/client/info_all.sh @@ -3,6 +3,9 @@ set -ex ## A script to refresh all the cached info json files +ruff format *.py +ruff check *.py + python osbv1_info.py python osb_info.py diff --git a/libraries/client/loadbiomodels.py b/libraries/client/loadbiomodels.py index 40882757..d4c3a0ce 100644 --- a/libraries/client/loadbiomodels.py +++ b/libraries/client/loadbiomodels.py @@ -50,9 +50,11 @@ def main(): if "BIOMD" in model_id: model_link = f"[{model_id}](https://www.ebi.ac.uk/biomodels/{model_id})" info = get_model_info(model_id) - model_name = info["name"] + # model_name = info["name"] print("\n===============================================") - print(f" {model_id}: \n{pprint.pprint(info['name'])}--") + print( + f" {model_id} ({model_link}): \n{pprint.pformat(info['name'])}--" + ) count += 1 diff --git a/libraries/client/loadddandi.py b/libraries/client/loadddandi.py index f6adaa36..2b911822 100644 --- a/libraries/client/loadddandi.py +++ b/libraries/client/loadddandi.py @@ -6,14 +6,13 @@ import logging import json import sys +import csv from utils import get_tags_info from utils import known_users, lookup_user from workspaces_cli.models import ( OSBRepository, - RepositoryType, - Tag, RepositoryContentType, ) # Defining the host is optional and defaults to http://localhost/api @@ -76,7 +75,6 @@ dandishowcase_csv_url = "https://raw.githubusercontent.com/OpenSourceBrain/DANDIArchiveShowcase/main/validation_folder/dandiset_summary.csv" response = urlopen(dandishowcase_csv_url) -import csv dandishowcase_info_reader = csv.DictReader(codecs.iterdecode(response, "utf-8")) dandishowcase_info = list(dandishowcase_info_reader) @@ -104,7 +102,7 @@ def add_dandiset(dandishowcase_entry, index): dandi_api_info = api_instance.get_info( uri=dandiset_url, repository_type="dandi" ) - except: + except Exception: but_ok = ( " (known to be missing...)" if dandiset_url in known_missing_dandisets @@ -159,7 +157,7 @@ def add_dandiset(dandishowcase_entry, index): " %s already exists (owner: %s); updating..." % (dandiset_url, lookup_user(r.user_id, url_info)) ) - except: + except Exception: exit(-1) print(url_info) all_updated.append(url_info) @@ -236,7 +234,7 @@ def add_dandiset(dandishowcase_entry, index): continue try: added = add_dandiset(dandishowcase_entry, index) - except Exception as e: + except Exception: logging.exception( "Error adding/updating %s" % dandishowcase_entry["url"] ) diff --git a/libraries/client/loadmodeldb.py b/libraries/client/loadmodeldb.py index 85445165..fadca49a 100644 --- a/libraries/client/loadmodeldb.py +++ b/libraries/client/loadmodeldb.py @@ -1,5 +1,3 @@ -from urllib.request import urlopen -import codecs import workspaces_cli from pprint import pprint from workspaces_cli.api import rest_api, k8s_api @@ -12,8 +10,6 @@ from workspaces_cli.models import ( OSBRepository, - RepositoryType, - Tag, RepositoryContentType, ) # Defining the host is optional and defaults to http://localhost/api @@ -82,7 +78,7 @@ def add_modeldb_model(modeldb_model, index): modeldb_model_id = modeldb_model["id"] - if not "osbv2_gh_repo" in modeldb_model or not modeldb_model["osbv2_gh_repo"]: + if "osbv2_gh_repo" not in modeldb_model or not modeldb_model["osbv2_gh_repo"]: all_errors.append( " %i, %s (%s) doesn't have a Github repo..." % (index, modeldb_model["name"], modeldb_model_id) @@ -149,7 +145,7 @@ def add_modeldb_model(modeldb_model, index): " %s already exists (owner: %s); updating..." % (modeldb_model_id, lookup_user(existing_repo.user_id, url_info)) ) - except: + except Exception: exit(-1) print(url_info) all_updated.append(url_info) @@ -239,7 +235,7 @@ def add_modeldb_model(modeldb_model, index): print("----------") print("Error: %s" % str(e)) print("----------") - if not "context_resources" in str(e): + if "context_resources" not in str(e): print("Exiting due to unknown error...") exit() else: diff --git a/libraries/client/loadosbv1.py b/libraries/client/loadosbv1.py index 08f874e2..f8c4eace 100644 --- a/libraries/client/loadosbv1.py +++ b/libraries/client/loadosbv1.py @@ -1,23 +1,20 @@ -from urllib.request import urlopen -import codecs import workspaces_cli from pprint import pprint from workspaces_cli.api import rest_api, k8s_api import logging import json import sys +from workspaces_cli.models import ( + OSBRepository, + RepositoryContentType, +) from utils import get_tags_info from utils import known_users, lookup_user known_ignores = ["dentate", "nc_superdeep", "tvb_neuroml"] -from workspaces_cli.models import ( - OSBRepository, - RepositoryType, - Tag, - RepositoryContentType, -) + # Defining the host is optional and defaults to http://localhost/api # See configuration.py for a list of all supported configuration parameters. @@ -84,7 +81,7 @@ def add_osbv1_project(osbv1_proj, index): osbv1_proj_id = osbv1_proj["identifier"] - if not "GitHub repository" in osbv1_proj: + if "GitHub repository" not in osbv1_proj: but_ok = ( " (but it is in the list of known projects to ignore)" if osbv1_proj_id in known_ignores @@ -150,7 +147,7 @@ def add_osbv1_project(osbv1_proj, index): " %s already exists (owner: %s); updating..." % (osbv1_proj_id, lookup_user(r.user_id, url_info)) ) - except: + except Exception: exit(-1) print(url_info) all_updated.append(url_info) @@ -230,7 +227,7 @@ def add_osbv1_project(osbv1_proj, index): print("----------") print("Error: %s" % str(e)) print("----------") - if not "context_resources" in str(e): + if "context_resources" not in str(e): print("Exiting due to unknown error...") exit() else: diff --git a/libraries/client/modeldb_info.py b/libraries/client/modeldb_info.py index b918bf61..695a1fdf 100644 --- a/libraries/client/modeldb_info.py +++ b/libraries/client/modeldb_info.py @@ -5,8 +5,6 @@ import sys import json -import osb -import operator import pprint from utils import get_github @@ -87,7 +85,7 @@ info[model]["osbv2_gh_repo"] = repo_to_use.html_url info[model]["osbv2_gh_branch"] = repo_to_use.default_branch - except: + except Exception: print( " Missing fork: %s, forking now: %s" % (possible_osbgh_repo, fork_if_missing) @@ -110,7 +108,7 @@ to_be_forked.append(msg) if (not mdb_repo.forks == expected_forks) and ( - not (info[model]["id"] in known_to_have_other_forks) + info[model]["id"] not in known_to_have_other_forks ): msg = " Unexpected forks for %i (%s != %s)..." % ( info[model]["id"], @@ -120,7 +118,7 @@ print(msg) many_forks.append(msg) - except: + except Exception: msg = " Problem locating repo for: %i (%i/%i) %s" % ( info[model]["id"], index, diff --git a/libraries/client/osb_info.py b/libraries/client/osb_info.py index a25e9ecd..686c8b43 100644 --- a/libraries/client/osb_info.py +++ b/libraries/client/osb_info.py @@ -3,22 +3,12 @@ # the current contents. Makes it easier to track (small) changes following API calls ###################################################################################### -from urllib.request import urlopen -import codecs import workspaces_cli from pprint import pprint from workspaces_cli.api import rest_api, k8s_api -import logging -import datetime import json import sys -from workspaces_cli.models import ( - OSBRepository, - RepositoryType, - Tag, - RepositoryContentType, -) # Defining the host is optional and defaults to http://localhost/api # See configuration.py for a list of all supported configuration parameters. @@ -70,14 +60,14 @@ try: print("Checking page %i" % page) found = api_instance.osbrepository_get( - q=f"uri__like=/", per_page=500, page=page + q="uri__like=/", per_page=500, page=page ) for f in found.osbrepositories: all_found.append(f) print("Found so far: %i" % len(all_found)) page += 1 # if page>3: break - except: + except Exception: print("All done") break diff --git a/libraries/client/osbv1_info.py b/libraries/client/osbv1_info.py index 3822ea00..7ae6c804 100644 --- a/libraries/client/osbv1_info.py +++ b/libraries/client/osbv1_info.py @@ -77,7 +77,7 @@ print(" Project has tags: %s" % (project.tags)) with_tags += 1 for tag in project.tags: - if not tag in tags: + if tag not in tags: tags[tag] = 0 tags[tag] += 1 diff --git a/libraries/client/utils.py b/libraries/client/utils.py index 5f86cb17..b719664c 100644 --- a/libraries/client/utils.py +++ b/libraries/client/utils.py @@ -13,7 +13,7 @@ def lookup_user(uid, url): - if not uid in known_users.values(): + if uid not in known_users.values(): raise Exception("Unknown user: %s;%s" % (uid, url)) for user in known_users: if uid == known_users[user]: @@ -51,10 +51,10 @@ def get_tags_info( for field in ["Original format", "Cell type", "Brain region", "Specie"]: if field in osbv1_info: val = osbv1_info[field] - if not val in ["None", "Other", ""]: + if val not in ["None", "Other", ""]: val = val.replace("PV+", "PV") val = val.replace("C++", "Cplusplus") - if not val in tags: + if val not in tags: tags.append(val) if dandi_api_info is not None: diff --git a/libraries/client/workspaces/workspaces_cli/model/osb_repository_base.py b/libraries/client/workspaces/workspaces_cli/model/osb_repository_base.py index bdda3c7f..ec73344b 100644 --- a/libraries/client/workspaces/workspaces_cli/model/osb_repository_base.py +++ b/libraries/client/workspaces/workspaces_cli/model/osb_repository_base.py @@ -312,7 +312,7 @@ def __init__(self, name, repository_type, content_types, uri, *args, **kwargs): continue try: setattr(self, var_name, var_value) - except: + except Exception: pass if var_name in self.read_only_vars: