File tree 2 files changed +13
-10
lines changed
2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 9
9
from entitysdk .exception import EntitySDKError
10
10
from entitysdk .typedef import DeploymentEnvironment
11
11
12
+ UUID_RE = "[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}"
13
+
14
+
12
15
VLAB_URL_PATTERN = re .compile (
13
- r"^https:\/\/(?:(?P<staging >staging)\.)? openbraininstitute\.org"
14
- r "\/app\/virtual-lab\/lab\/(?P<vlab>[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12 })"
15
- r "\/project\/(?P<proj>[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12 })(?:\/.*)?$"
16
+ r"^https:\/\/(?P<env >staging|www)?\. openbraininstitute\.org"
17
+ rf "\/app\/virtual-lab\/lab\/(?P<vlab>{ UUID_RE } )"
18
+ rf "\/project\/(?P<proj>{ UUID_RE } )(?:\/.*)?$"
16
19
)
17
20
18
21
@@ -31,11 +34,11 @@ def from_vlab_url(cls, url: str) -> Self:
31
34
if not result :
32
35
raise EntitySDKError (f"Badly formed vlab url: { url } " )
33
36
34
- env = (
35
- DeploymentEnvironment .staging
36
- if result . group ( "staging" )
37
- else DeploymentEnvironment . production
38
- )
37
+ env = {
38
+ "www" : DeploymentEnvironment .production ,
39
+ "staging" : DeploymentEnvironment . staging ,
40
+ }[ result . group ( "env" )]
41
+
39
42
vlab_id = UUID (result .group ("vlab" ))
40
43
proj_id = UUID (result .group ("proj" ))
41
44
Original file line number Diff line number Diff line change 28
28
),
29
29
),
30
30
(
31
- f"https://openbraininstitute.org/app/virtual-lab/lab/{ VLAB_ID } /project/{ PROJ_ID } /home" ,
31
+ f"https://www. openbraininstitute.org/app/virtual-lab/lab/{ VLAB_ID } /project/{ PROJ_ID } /home" ,
32
32
test_module .ProjectContext (
33
33
virtual_lab_id = VLAB_ID ,
34
34
project_id = PROJ_ID ,
35
35
environment = DeploymentEnvironment .production ,
36
36
),
37
37
),
38
38
(
39
- f"https://openbraininstitute.org/app/virtual-lab/lab/{ VLAB_ID } /project/{ PROJ_ID } " ,
39
+ f"https://www. openbraininstitute.org/app/virtual-lab/lab/{ VLAB_ID } /project/{ PROJ_ID } " ,
40
40
test_module .ProjectContext (
41
41
virtual_lab_id = VLAB_ID ,
42
42
project_id = PROJ_ID ,
You can’t perform that action at this time.
0 commit comments