Skip to content

Commit b970c57

Browse files
committed
use GH cli to get list of neuron simulator models
1 parent 7bac176 commit b970c57

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

.github/workflows/nrn-modeldb-ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ jobs:
130130
id: install-deps
131131
run: |
132132
set
133+
# Install GH cli
134+
sudo apt-get install gh
133135
# Set up Xvfb
134136
sudo apt-get install xvfb
135137
sudo /usr/bin/Xvfb $DISPLAY -screen 0 1600x1200x24 -noreset -nolock -shmem & # run in bg

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ The following commands are now available:
6666
| MODELDB_RUN_FILE | yaml file containing run instructions for models (required for `runmodels`) |
6767
| MODELDB_METADATA_FILE | yaml file containing model info for those downloaded with `getmodels` |
6868
| MODELS_ZIP_DIR | location of cache folder for models populated via `getmodels` |
69-
| MDB_NEURON_MODELS_URL | url used to get list of all NEURON model ids (necessary for `getmodels`) |
70-
| MDB_MODEL_DOWNLOAD_URL | url template used for model downloading (cf `{model_id}`) |
7169

7270
## Model Run
7371

modeldb/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def modeldb_config(args=None):
142142
143143
Examples
144144
modeldb-config
145-
modeldb-config --item=MDB_NEURON_MODELS_URL
145+
modeldb-config --item=MODELS_ZIP_DIR
146146
"""
147147
options = docopt(modeldb_config.__doc__, args)
148148
item = options.pop("--item", None)

modeldb/config.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
import os
44

5-
MDB_NEURON_MODELS_URL = (
6-
"http://modeldb.science/api/v1/models?modeling_application=NEURON"
7-
)
8-
95
ROOT_DIR = os.path.abspath(__file__ + "/../../")
106

117
MODELS_ZIP_DIR = "%s/cache" % ROOT_DIR

modeldb/modeldb.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import traceback
1212
from pprint import pformat
1313

14+
1415
def download_model(arg_tuple):
1516
model_id, model_run_info = arg_tuple
1617
try:
@@ -60,11 +61,23 @@ def __init__(self):
6061
except Exception as e:
6162
raise e
6263

64+
def _gh_cli_get_neuron_simulator_repositories(self):
65+
import subprocess
66+
67+
# Run the gh command to fetch the repository list and capture the output
68+
command = ['gh', 'repo', 'list', 'modeldbrepository', '--topic', 'neuron-simulator', '--json', 'name', '-L', '2000']
69+
output = subprocess.check_output(command, text=True)
70+
71+
# Parse the json output to get the repository names
72+
import json
73+
repositories = json.loads(output)
74+
return [int(repository['name']) for repository in repositories]
75+
6376
def _download_models(self, model_list=None):
6477
if not os.path.isdir(MODELS_ZIP_DIR):
6578
logging.info("Creating cache directory: {}".format(MODELS_ZIP_DIR))
6679
os.mkdir(MODELS_ZIP_DIR)
67-
models = requests.get(MDB_NEURON_MODELS_URL).json() if model_list is None else model_list
80+
models = self._gh_cli_get_neuron_simulator_repositories() if model_list is None else model_list
6881
pool = multiprocessing.Pool()
6982
processed_models = pool.imap_unordered(
7083
download_model,

0 commit comments

Comments
 (0)