Skip to content

Commit 21389f8

Browse files
committed
fix: bohrium authorization expires
Signed-off-by: zjgemi <[email protected]>
1 parent f76a60e commit 21389f8

File tree

9 files changed

+21
-20
lines changed

9 files changed

+21
-20
lines changed

src/dflow/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
from .argo_objects import ArgoStep, ArgoWorkflow
55
from .code_gen import gen_code
66
from .common import (CustomArtifact, HTTPArtifact, LineageClient,
7-
LocalArtifact, S3Artifact, import_func)
8-
from .common import jsonpickle
7+
LocalArtifact, S3Artifact, import_func, jsonpickle)
98
from .config import config, s3_config, set_config, set_s3_config
109
from .context import Context
1110
from .dag import DAG

src/dflow/code_gen.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
import json
33

44
from .common import (input_artifact_pattern, input_parameter_pattern,
5-
step_output_artifact_pattern,
5+
jsonpickle, step_output_artifact_pattern,
66
step_output_parameter_pattern,
77
task_output_artifact_pattern,
88
task_output_parameter_pattern)
9-
from .common import jsonpickle
109
from .config import config
1110
from .dag import DAG
1211
from .io import InputArtifact, InputParameter, OutputArtifact, OutputParameter

src/dflow/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import os
21
import json
2+
import os
33
import tempfile
44

55

src/dflow/context_syntax.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import warnings
2-
from typing import Union, List, Any
2+
from typing import Any, List, Union
33

44
dflow = Any
55

src/dflow/io.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
from .utils import randstr, s3_config, upload_s3
1111

1212
try:
13-
from argo.workflows.client import (V1alpha1ArchiveStrategy, V1alpha1Inputs,
14-
V1alpha1HTTPArtifact, V1alpha1Outputs,
15-
V1alpha1RawArtifact)
13+
from argo.workflows.client import (V1alpha1ArchiveStrategy,
14+
V1alpha1HTTPArtifact, V1alpha1Inputs,
15+
V1alpha1Outputs, V1alpha1RawArtifact)
1616

1717
from .client import V1alpha1Artifact, V1alpha1Parameter, V1alpha1ValueFrom
1818
except Exception:

src/dflow/plugins/bohrium.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ def login(username=None, phone=None, password=None, bohrium_url=None):
5050
password = config["password"]
5151
if bohrium_url is None:
5252
bohrium_url = config["bohrium_url"]
53-
if config["authorization"] is None:
54-
config["authorization"] = _login(
55-
bohrium_url + "/account/login", username, phone, password)
56-
update_headers()
53+
config["authorization"] = _login(
54+
bohrium_url + "/account/login", username, phone, password)
55+
update_headers()
5756
return config["authorization"]
5857

5958

@@ -290,7 +289,7 @@ def __getstate__(self):
290289
def __setstate__(self, d):
291290
self.__dict__.update(d)
292291

293-
def get_token(self):
292+
def get_token(self, retry=1):
294293
import requests
295294
url = self.bohrium_url + "/brm/v1/storage/token"
296295
headers = {
@@ -309,6 +308,10 @@ def get_token(self):
309308
headers["Authorization"] = "Bearer " + self.authorization
310309
rsp = requests.get(url, headers=headers, params=params)
311310
if not rsp.text:
311+
if retry > 0:
312+
self.authorization = None
313+
self.get_token(retry=retry-1)
314+
return
312315
raise RuntimeError("Bohrium unauthorized")
313316
res = json.loads(rsp.text)
314317
_raise_error(res, "get storage token")

src/dflow/plugins/dispatcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import abc
22
import json
33
import os
4+
import re
45
from abc import ABC
56
from copy import deepcopy
67
from getpass import getpass
7-
import re
88
from typing import Dict, List, Optional, Union
99

1010
from ..common import CustomArtifact, S3Artifact

src/dflow/plugins/ray.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from copy import deepcopy
2-
from typing import Union, List, Optional, Any
2+
from typing import Any, List, Optional, Union
33

44
from dflow.executor import Executor
55
from dflow.op_template import ScriptOPTemplate
66
from dflow.utils import randstr
77

88
try:
9-
from argo.workflows.client import (V1Volume, V1VolumeMount,
10-
V1alpha1UserContainer,
11-
V1EmptyDirVolumeSource)
9+
from argo.workflows.client import (V1alpha1UserContainer,
10+
V1EmptyDirVolumeSource, V1Volume,
11+
V1VolumeMount)
1212
except ImportError:
1313
pass
1414

src/dflow/slurm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import re
33
from copy import deepcopy
4-
from typing import Optional, Dict, List, Union
4+
from typing import Dict, List, Optional, Union
55

66
from .config import config
77
from .executor import (Executor, RemoteExecutor, render_script_with_tmp_root,

0 commit comments

Comments
 (0)