Skip to content

Commit 5c3bf0e

Browse files
committed
minor cleanup
1 parent 66ccb86 commit 5c3bf0e

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

tests/performance/locust_files/functions/workflow.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import random
33
from pathlib import Path
44
from tempfile import TemporaryDirectory
5-
from typing import Final
65
from uuid import UUID
76

87
from locust import HttpUser, task
@@ -11,9 +10,6 @@
1110
from requests.auth import HTTPBasicAuth
1211
from urllib3 import PoolManager, Retry
1312

14-
_MAX_WAIT_SECONDS: Final[int] = 60
15-
16-
1713
# Perform the following setup in order to run this load test:
1814
# 1. Copy .env-devel to .env in this directory and add your osparc keys to .env.
1915
# 2. Construct a study **template** according to study_template.png. passer.py is the file next to this file.
@@ -95,39 +91,36 @@ def __init__(self, *args, **kwargs):
9591

9692
self._function_uid = None
9793
self._input_json_uuid = None
98-
self._job_uuid = None
94+
self._script_uuid = None
95+
self._run_uid = None
9996

10097
super().__init__(*args, **kwargs)
10198

10299
def on_stop(self) -> None:
103100
if self._script_uuid is not None:
104-
response = self.client.delete(
101+
_ = self.client.delete(
105102
f"/v0/files/{self._script_uuid}",
106103
name="/v0/files/[file_id]",
107104
auth=self._auth,
108105
)
109-
response.raise_for_status()
110106
if self._input_json_uuid is not None:
111-
response = self.client.delete(
107+
_ = self.client.delete(
112108
f"/v0/files/{self._input_json_uuid}",
113109
name="/v0/files/[file_id]",
114110
auth=self._auth,
115111
)
116-
response.raise_for_status()
117112
if self._function_uid is not None:
118-
response = self.client.delete(
113+
_ = self.client.delete(
119114
f"/v0/functions/{self._function_uid}",
120115
name="/v0/functions/[function_uid]",
121116
auth=self._auth,
122117
)
123-
response.raise_for_status()
124118
if self._run_uid is not None:
125-
response = self.client.delete(
119+
_ = self.client.delete(
126120
f"/v0/function_jobs/{self._run_uid}",
127121
name="/v0/function_jobs/[function_run_uid]",
128122
auth=self._auth,
129123
)
130-
response.raise_for_status()
131124

132125
@task
133126
def run_function(self):
@@ -142,13 +135,13 @@ def run_function(self):
142135
input_json.write_text(json.dumps(inputs))
143136
self._input_json_uuid = self.upload_file(input_json)
144137

145-
function = Function(
138+
_function = Function(
146139
title="Test function",
147140
description="Test function",
148141
default_inputs={"input_0": f"{self._script_uuid}"},
149142
)
150143
response = self.client.post(
151-
"/v0/functions", json=function.model_dump(), auth=self._auth
144+
"/v0/functions", json=_function.model_dump(), auth=self._auth
152145
)
153146
response.raise_for_status()
154147
self._function_uid = response.json().get("uid")
@@ -177,7 +170,7 @@ def run_function(self):
177170

178171
def upload_file(self, file: Path) -> UUID:
179172
assert file.is_file()
180-
with open(f"{file.resolve()}", "rb") as f:
173+
with file.open(mode="rb") as f:
181174
files = {"file": f}
182175
response = self.client.put(
183176
"/v0/files/content", files=files, auth=self._auth

0 commit comments

Comments
 (0)