|
7 | 7 | """
|
8 | 8 |
|
9 | 9 | import os
|
| 10 | +from typing import Union |
10 | 11 |
|
11 | 12 |
|
12 | 13 | class Config(object):
|
@@ -36,30 +37,27 @@ class Config(object):
|
36 | 37 | runbiosimulations_api_endpoint (:obj:`str`): Base URL for the runBioSimulations API
|
37 | 38 | test_case_timeout (:obj:`int`): time out for test cases in seconds
|
38 | 39 | user_to_exec_in_simulator_containers (:obj:`str` or :obj:`None`): user id or name to execute calls inside simulator containers
|
39 |
| -
|
40 | 40 | * Use ``_CURRENT_USER_`` to indicate that the Docker container should execute commands as the current user (``os.getuid()``)
|
41 | 41 | * Use the format ``<name|uid>[:<group|gid>]`` to indicate any other user/group that the Docker container should use to
|
42 | 42 | execute commands
|
43 |
| -
|
44 | 43 | singularity_image_dirname (:obj:`str`): directory to save Singularity images
|
45 | 44 | """
|
46 | 45 |
|
47 | 46 | def __init__(self,
|
48 |
| - pull_docker_image=None, docker_hub_username=None, docker_hub_token=None, |
49 |
| - biosimulators_auth_endpoint=None, biosimulators_audience=None, |
50 |
| - biosimulators_api_client_id=None, biosimulators_api_client_secret=None, |
51 |
| - biosimulators_prod_api_endpoint=None, |
52 |
| - biosimulators_dev_api_endpoint=None, |
53 |
| - biosimulators_curator_gh_ids=None, biosimulators_default_specifications_version=None, |
54 |
| - biosimulators_default_image_version=None, biosimulators_docker_registry_url=None, |
55 |
| - biosimulators_docker_registry_username=None, biosimulators_docker_registry_token=None, |
56 |
| - biosimulators_docker_image_url_pattern=None, |
57 |
| - runbiosimulations_auth_endpoint=None, runbiosimulations_audience=None, |
58 |
| - runbiosimulations_api_client_id=None, runbiosimulations_api_client_secret=None, |
59 |
| - runbiosimulations_api_endpoint=None, |
60 |
| - test_case_timeout=None, |
61 |
| - user_to_exec_in_simulator_containers=None, |
62 |
| - singularity_image_dirname=None): |
| 47 | + pull_docker_image: bool = None, docker_hub_username: str = None, docker_hub_token: str = None, |
| 48 | + biosimulators_auth_endpoint: str = None, biosimulators_audience: str = None, |
| 49 | + biosimulators_api_client_id: str = None, biosimulators_api_client_secret: str = None, |
| 50 | + biosimulators_prod_api_endpoint: str = None, biosimulators_dev_api_endpoint: str = None, |
| 51 | + biosimulators_curator_gh_ids: "list[str]" = None, biosimulators_default_specifications_version: str = None, |
| 52 | + biosimulators_default_image_version: str = None, biosimulators_docker_registry_url: str = None, |
| 53 | + biosimulators_docker_registry_username: str = None, biosimulators_docker_registry_token: str = None, |
| 54 | + biosimulators_docker_image_url_pattern: str = None, |
| 55 | + runbiosimulations_auth_endpoint: str = None, runbiosimulations_audience: str = None, |
| 56 | + runbiosimulations_api_client_id: str = None, runbiosimulations_api_client_secret: str = None, |
| 57 | + runbiosimulations_api_endpoint: str = None, |
| 58 | + test_case_timeout: int = None, |
| 59 | + user_to_exec_in_simulator_containers: "Union[str, None]" = None, |
| 60 | + singularity_image_dirname: str = None): |
63 | 61 | """
|
64 | 62 | Args:
|
65 | 63 | pull_docker_image (:obj:`bool`, optional): whether to pull the Docker image for the simulator (default: :obj:`True`)
|
@@ -94,134 +92,135 @@ def __init__(self,
|
94 | 92 | """
|
95 | 93 | # Docker registry
|
96 | 94 | if pull_docker_image is None:
|
97 |
| - self.pull_docker_image = os.getenv('PULL_DOCKER_IMAGE', '1').lower() in ['1', 'true'] |
| 95 | + self.pull_docker_image: bool = os.getenv('PULL_DOCKER_IMAGE', '1').lower() in ['1', 'true'] |
98 | 96 | else:
|
99 |
| - self.pull_docker_image = pull_docker_image |
| 97 | + self.pull_docker_image: bool = pull_docker_image |
100 | 98 |
|
101 | 99 | # Docker Hub
|
102 | 100 | if docker_hub_username is None:
|
103 |
| - self.docker_hub_username = os.getenv('DOCKER_HUB_USERNAME') |
| 101 | + self.docker_hub_username: str = os.getenv('DOCKER_HUB_USERNAME') |
104 | 102 | else:
|
105 |
| - self.docker_hub_username = docker_hub_username |
| 103 | + self.docker_hub_username: str = docker_hub_username |
106 | 104 |
|
107 | 105 | if docker_hub_token is None:
|
108 |
| - self.docker_hub_token = os.getenv('DOCKER_HUB_TOKEN') |
| 106 | + self.docker_hub_token: str = os.getenv('DOCKER_HUB_TOKEN') |
109 | 107 | else:
|
110 |
| - self.docker_hub_token = docker_hub_token |
| 108 | + self.docker_hub_token: str = docker_hub_token |
111 | 109 |
|
112 | 110 | # BioSimulators
|
113 | 111 | if biosimulators_auth_endpoint is None:
|
114 |
| - self.biosimulators_auth_endpoint = os.getenv('BIOSIMULATORS_AUTH_ENDPOINT', 'https://auth.biosimulations.org/oauth/token') |
| 112 | + self.biosimulators_auth_endpoint: str = os.getenv('BIOSIMULATORS_AUTH_ENDPOINT', 'https://auth.biosimulations.org/oauth/token') |
115 | 113 | else:
|
116 |
| - self.biosimulators_auth_endpoint = biosimulators_auth_endpoint |
| 114 | + self.biosimulators_auth_endpoint: str = biosimulators_auth_endpoint |
117 | 115 |
|
118 | 116 | if biosimulators_audience is None:
|
119 |
| - self.biosimulators_audience = os.getenv('BIOSIMULATORS_AUDIENCE', 'api.biosimulators.org') |
| 117 | + self.biosimulators_audience: str = os.getenv('BIOSIMULATORS_AUDIENCE', 'api.biosimulators.org') |
120 | 118 | else:
|
121 |
| - self.biosimulators_audience = biosimulators_audience |
| 119 | + self.biosimulators_audience: str = biosimulators_audience |
122 | 120 |
|
123 | 121 | if biosimulators_api_client_id is None:
|
124 |
| - self.biosimulators_api_client_id = os.getenv('BIOSIMULATORS_API_CLIENT_ID') |
| 122 | + self.biosimulators_api_client_id: str = os.getenv('BIOSIMULATORS_API_CLIENT_ID') |
125 | 123 | else:
|
126 |
| - self.biosimulators_api_client_id = biosimulators_api_client_id |
| 124 | + self.biosimulators_api_client_id: str = biosimulators_api_client_id |
127 | 125 |
|
128 | 126 | if biosimulators_api_client_secret is None:
|
129 |
| - self.biosimulators_api_client_secret = os.getenv('BIOSIMULATORS_API_CLIENT_SECRET') |
| 127 | + self.biosimulators_api_client_secret: str = os.getenv('BIOSIMULATORS_API_CLIENT_SECRET') |
130 | 128 | else:
|
131 |
| - self.biosimulators_api_client_secret = biosimulators_api_client_secret |
| 129 | + self.biosimulators_api_client_secret: str = biosimulators_api_client_secret |
132 | 130 |
|
133 | 131 | if biosimulators_prod_api_endpoint is None:
|
134 |
| - self.biosimulators_prod_api_endpoint = os.getenv('BIOSIMULATORS_PROD_API_ENDPOINT', 'https://api.biosimulators.org/') |
| 132 | + self.biosimulators_prod_api_endpoint: str = os.getenv('BIOSIMULATORS_PROD_API_ENDPOINT', 'https://api.biosimulators.org/') |
135 | 133 | else:
|
136 |
| - self.biosimulators_prod_api_endpoint = biosimulators_prod_api_endpoint |
| 134 | + self.biosimulators_prod_api_endpoint: str = biosimulators_prod_api_endpoint |
137 | 135 |
|
138 | 136 | if biosimulators_dev_api_endpoint is None:
|
139 |
| - self.biosimulators_dev_api_endpoint = os.getenv('BIOSIMULATORS_DEV_API_ENDPOINT', 'https://api.biosimulators.dev/') |
| 137 | + self.biosimulators_dev_api_endpoint: str = os.getenv('BIOSIMULATORS_DEV_API_ENDPOINT', 'https://api.biosimulators.dev/') |
140 | 138 | else:
|
141 |
| - self.biosimulators_dev_api_endpoint = biosimulators_dev_api_endpoint |
| 139 | + self.biosimulators_dev_api_endpoint: str = biosimulators_dev_api_endpoint |
142 | 140 |
|
143 | 141 | if biosimulators_curator_gh_ids is None:
|
144 | 142 | ids = os.getenv('BIOSIMULATORS_CURATOR_GH_IDS', 'jonrkarr').strip()
|
145 | 143 | if ids:
|
146 |
| - self.biosimulators_curator_gh_ids = [id.strip() for id in ids.split(',')] |
| 144 | + self.biosimulators_curator_gh_ids: "list[str]" = [id.strip() for id in ids.split(',')] |
147 | 145 | else:
|
148 |
| - self.biosimulators_curator_gh_ids = [] |
| 146 | + self.biosimulators_curator_gh_ids: "list[str]" = [] |
149 | 147 | else:
|
150 |
| - self.biosimulators_curator_gh_ids = biosimulators_curator_gh_ids |
| 148 | + self.biosimulators_curator_gh_ids: "list[str]" = biosimulators_curator_gh_ids |
151 | 149 |
|
152 | 150 | if biosimulators_default_specifications_version is None:
|
153 |
| - self.biosimulators_default_specifications_version = os.getenv('BIOSIMULATORS_DEFAULT_SPECIFICATIONS_VERSION', '1.0.0') |
| 151 | + self.biosimulators_default_specifications_version: str = os.getenv('BIOSIMULATORS_DEFAULT_SPECIFICATIONS_VERSION', '1.0.0') |
154 | 152 | else:
|
155 |
| - self.biosimulators_default_specifications_version = biosimulators_default_specifications_version |
| 153 | + self.biosimulators_default_specifications_version: str = biosimulators_default_specifications_version |
156 | 154 |
|
157 | 155 | if biosimulators_default_image_version is None:
|
158 |
| - self.biosimulators_default_image_version = os.getenv('BIOSIMULATORS_DEFAULT_IMAGE_VERSION', '1.0.0') |
| 156 | + self.biosimulators_default_image_version: str = os.getenv('BIOSIMULATORS_DEFAULT_IMAGE_VERSION', '1.0.0') |
159 | 157 | else:
|
160 |
| - self.biosimulators_default_image_version = biosimulators_default_image_version |
| 158 | + self.biosimulators_default_image_version: str = biosimulators_default_image_version |
161 | 159 |
|
162 | 160 | if biosimulators_docker_registry_url is None:
|
163 |
| - self.biosimulators_docker_registry_url = os.getenv( |
| 161 | + self.biosimulators_docker_registry_url: str = os.getenv( |
164 | 162 | 'BIOSIMULATORS_DOCKER_REGISTRY_URL', os.getenv('DOCKER_REGISTRY_URL', 'ghcr.io'))
|
165 | 163 | else:
|
166 |
| - self.biosimulators_docker_registry_url = biosimulators_docker_registry_url |
| 164 | + self.biosimulators_docker_registry_url: str = biosimulators_docker_registry_url |
167 | 165 |
|
168 | 166 | if biosimulators_docker_registry_username is None:
|
169 |
| - self.biosimulators_docker_registry_username = os.getenv( |
| 167 | + self.biosimulators_docker_registry_username: str = os.getenv( |
170 | 168 | 'BIOSIMULATORS_DOCKER_REGISTRY_USERNAME', os.getenv('DOCKER_REGISTRY_USERNAME'))
|
171 | 169 | else:
|
172 |
| - self.biosimulators_docker_registry_username = biosimulators_docker_registry_username |
| 170 | + self.biosimulators_docker_registry_username: str = biosimulators_docker_registry_username |
173 | 171 |
|
174 | 172 | if biosimulators_docker_registry_token is None:
|
175 |
| - self.biosimulators_docker_registry_token = os.getenv( |
| 173 | + self.biosimulators_docker_registry_token: str = os.getenv( |
176 | 174 | 'BIOSIMULATORS_DOCKER_REGISTRY_TOKEN', os.getenv('DOCKER_REGISTRY_TOKEN'))
|
177 | 175 | else:
|
178 |
| - self.biosimulators_docker_registry_token = biosimulators_docker_registry_token |
| 176 | + self.biosimulators_docker_registry_token: str = biosimulators_docker_registry_token |
179 | 177 |
|
180 | 178 | if biosimulators_docker_image_url_pattern is None:
|
181 |
| - self.biosimulators_docker_image_url_pattern = os.getenv( |
| 179 | + self.biosimulators_docker_image_url_pattern: str = os.getenv( |
182 | 180 | 'BIOSIMULATORS_DOCKER_REGISTRY_IMAGE_URL_PATTERN', 'ghcr.io/biosimulators/{}:{}')
|
183 | 181 | else:
|
184 |
| - self.biosimulators_docker_image_url_pattern = biosimulators_docker_image_url_pattern |
| 182 | + self.biosimulators_docker_image_url_pattern: str = biosimulators_docker_image_url_pattern |
185 | 183 |
|
186 | 184 | # runBioSimulations
|
187 | 185 | if runbiosimulations_auth_endpoint is None:
|
188 |
| - self.runbiosimulations_auth_endpoint = os.getenv( |
| 186 | + self.runbiosimulations_auth_endpoint: str = os.getenv( |
189 | 187 | 'RUNBIOSIMULATIONS_AUTH_ENDPOINT', 'https://auth.biosimulations.org/oauth/token')
|
190 | 188 | else:
|
191 |
| - self.runbiosimulations_auth_endpoint = runbiosimulations_auth_endpoint |
| 189 | + self.runbiosimulations_auth_endpoint: str = runbiosimulations_auth_endpoint |
192 | 190 |
|
193 | 191 | if runbiosimulations_audience is None:
|
194 |
| - self.runbiosimulations_audience = os.getenv('RUNBIOSIMULATIONS_AUDIENCE', 'api.biosimulations.org') |
| 192 | + self.runbiosimulations_audience: str = os.getenv('RUNBIOSIMULATIONS_AUDIENCE', 'api.biosimulations.org') |
195 | 193 | else:
|
196 |
| - self.runbiosimulations_audience = runbiosimulations_audience |
| 194 | + self.runbiosimulations_audience: str = runbiosimulations_audience |
197 | 195 |
|
198 | 196 | if runbiosimulations_api_client_id is None:
|
199 |
| - self.runbiosimulations_api_client_id = os.getenv('RUNBIOSIMULATIONS_API_CLIENT_ID') |
| 197 | + self.runbiosimulations_api_client_id: str = os.getenv('RUNBIOSIMULATIONS_API_CLIENT_ID') |
200 | 198 | else:
|
201 |
| - self.runbiosimulations_api_client_id = runbiosimulations_api_client_id |
| 199 | + self.runbiosimulations_api_client_id: str = runbiosimulations_api_client_id |
202 | 200 |
|
203 | 201 | if runbiosimulations_api_client_secret is None:
|
204 |
| - self.runbiosimulations_api_client_secret = os.getenv('RUNBIOSIMULATIONS_API_CLIENT_SECRET') |
| 202 | + self.runbiosimulations_api_client_secret: str = os.getenv('RUNBIOSIMULATIONS_API_CLIENT_SECRET') |
205 | 203 | else:
|
206 |
| - self.runbiosimulations_api_client_secret = runbiosimulations_api_client_secret |
| 204 | + self.runbiosimulations_api_client_secret: str = runbiosimulations_api_client_secret |
207 | 205 |
|
208 | 206 | if runbiosimulations_api_endpoint is None:
|
209 |
| - self.runbiosimulations_api_endpoint = os.getenv('RUNBIOSIMULATIONS_API_ENDPOINT', 'https://api.biosimulations.org/') |
| 207 | + self.runbiosimulations_api_endpoint: str = os.getenv('RUNBIOSIMULATIONS_API_ENDPOINT', 'https://api.biosimulations.org/') |
210 | 208 | else:
|
211 |
| - self.runbiosimulations_api_endpoint = runbiosimulations_api_endpoint |
| 209 | + self.runbiosimulations_api_endpoint: str = runbiosimulations_api_endpoint |
212 | 210 |
|
213 | 211 | if test_case_timeout is None:
|
214 |
| - self.test_case_timeout = int(os.getenv('TEST_CASE_TIMEOUT', '600')) # seconds |
| 212 | + self.test_case_timeout: int = int(os.getenv('TEST_CASE_TIMEOUT', '600')) # seconds |
215 | 213 | else:
|
216 |
| - self.test_case_timeout = test_case_timeout |
| 214 | + self.test_case_timeout: int = test_case_timeout |
217 | 215 |
|
218 | 216 | if user_to_exec_in_simulator_containers is None:
|
219 |
| - self.user_to_exec_in_simulator_containers = os.getenv('USER_TO_EXEC_IN_SIMULATOR_CONTAINERS', '_CURRENT_USER_') or None |
| 217 | + self.user_to_exec_in_simulator_containers: "Union[str, None]" = os.getenv( |
| 218 | + 'USER_TO_EXEC_IN_SIMULATOR_CONTAINERS', '_CURRENT_USER_') or None |
220 | 219 | else:
|
221 |
| - self.user_to_exec_in_simulator_containers = user_to_exec_in_simulator_containers |
| 220 | + self.user_to_exec_in_simulator_containers: "Union[str, None]" = user_to_exec_in_simulator_containers |
222 | 221 |
|
223 | 222 | if singularity_image_dirname is None:
|
224 |
| - self.singularity_image_dirname = os.getenv('SINGULARITY_IMAGE_DIRNAME', |
225 |
| - os.path.join(os.path.expanduser('~'), '.biosimulators-test-suite', 'singularity')) |
| 223 | + self.singularity_image_dirname: str = os.getenv('SINGULARITY_IMAGE_DIRNAME', os.path.join(os.path.expanduser('~'), |
| 224 | + '.biosimulators-test-suite', 'singularity')) |
226 | 225 | else:
|
227 |
| - self.singularity_image_dirname = singularity_image_dirname |
| 226 | + self.singularity_image_dirname: str = singularity_image_dirname |
0 commit comments