Skip to content

Commit ad0960f

Browse files
committed
Ensure sender uses online mode, and allow server and token override
1 parent 18e66be commit ad0960f

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

simvue/config/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def fetch(
136136
cls,
137137
server_url: typing.Optional[str] = None,
138138
server_token: typing.Optional[str] = None,
139-
mode: typing.Literal["offline", "online", "disabled"] = "online",
139+
mode: typing.Optional[typing.Literal["offline", "online", "disabled"]] = None,
140140
) -> "SimvueConfiguration":
141141
"""Retrieve the Simvue configuration from this project
142142

simvue/sender.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ def get_json(filename, run_id=None, artifact=False):
8484
return data
8585

8686

87-
def sender() -> str:
87+
def sender(
88+
server_url: typing.Optional[str] = None, server_token: typing.Optional[str] = None
89+
) -> str:
8890
"""
8991
Asynchronous upload of runs to Simvue server
9092
"""
91-
directory = SimvueConfiguration.fetch().offline.cache
93+
directory = SimvueConfiguration.fetch(mode="offline").offline.cache
9294

9395
# Clean up old runs after waiting 5 mins
9496
runs = glob.glob(f"{directory}/*/sent")
@@ -116,13 +118,17 @@ def sender() -> str:
116118
logger.info("Lauching %d workers", NUM_PARALLEL_WORKERS)
117119
with ThreadPoolExecutor(NUM_PARALLEL_WORKERS) as executor:
118120
for run in runs:
119-
executor.submit(process(run))
121+
executor.submit(
122+
process(run, server_token=server_token, server_url=server_url)
123+
)
120124
return [executor.result() for _ in runs]
121125
else:
122126
return [process(run) for run in runs]
123127

124128

125-
def process(run) -> typing.Optional[str]:
129+
def process(
130+
run, server_url: typing.Optional[str], server_token: typing.Optional[str]
131+
) -> typing.Optional[str]:
126132
"""
127133
Handle updates for the specified run
128134
"""
@@ -173,7 +179,9 @@ def process(run) -> typing.Optional[str]:
173179
# Create run if it hasn't previously been created
174180
created_file = f"{current}/init"
175181
name = None
176-
config = SimvueConfiguration.fetch()
182+
config = SimvueConfiguration.fetch(
183+
mode="online", server_token=server_token, server_url=server_url
184+
)
177185
if not os.path.isfile(created_file):
178186
remote = Remote(
179187
name=run_init["name"], uniq_id=id, config=config, suppress_errors=False

0 commit comments

Comments
 (0)