Skip to content

Commit 66c648d

Browse files
committed
Fix tag in test and address review comments
1 parent e666f9b commit 66c648d

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

simvue/run.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
if typing.TYPE_CHECKING:
5353
from .factory.proxy import SimvueBaseClass
5454
from .factory.dispatch import DispatcherBaseClass
55-
from .types import DeserializedContent
5655

5756
UPLOAD_TIMEOUT: int = 30
5857
HEARTBEAT_INTERVAL: int = 60
@@ -990,7 +989,24 @@ def save_object(
990989
name: typing.Optional[str] = None,
991990
allow_pickle: bool = False,
992991
) -> bool:
993-
obj: DeserializedContent
992+
"""Save an object to the Simvue server
993+
994+
Parameters
995+
----------
996+
obj : typing.Any
997+
object to serialize and send to the server
998+
category : Literal['input', 'output', 'code']
999+
category of file with respect to this run
1000+
name : str, optional
1001+
name to associate with this object, by default None
1002+
allow_pickle : bool, optional
1003+
whether to allow pickling if all other serialization types fail, by default False
1004+
1005+
Returns
1006+
-------
1007+
bool
1008+
whether object upload was successful
1009+
"""
9941010
serialized = serialize_object(obj, allow_pickle)
9951011

9961012
if not serialized or not (pickled := serialized[0]):
@@ -1022,7 +1038,7 @@ def save_object(
10221038
@pydantic.validate_call
10231039
def save_file(
10241040
self,
1025-
filename: pydantic.FilePath,
1041+
file_path: pydantic.FilePath,
10261042
category: typing.Literal["input", "output", "code"],
10271043
filetype: typing.Optional[str] = None,
10281044
preserve_path: bool = False,
@@ -1032,7 +1048,7 @@ def save_file(
10321048
10331049
Parameters
10341050
----------
1035-
filename : pydantic.FilePath
1051+
file_path : pydantic.FilePath
10361052
path to the file to upload
10371053
category : Literal['input', 'output', 'code']
10381054
category of file with respect to this run
@@ -1067,28 +1083,28 @@ def save_file(
10671083
self._error(f"Invalid MIME type '{filetype}' specified")
10681084
return False
10691085

1070-
stored_file_name: str = f"{filename}"
1086+
stored_file_name: str = f"{file_path}"
10711087

10721088
if preserve_path and stored_file_name.startswith("./"):
10731089
stored_file_name = stored_file_name[2:]
10741090
elif not preserve_path:
1075-
stored_file_name = os.path.basename(filename)
1091+
stored_file_name = os.path.basename(file_path)
10761092

10771093
# Determine mimetype
10781094
if not (mimetype := filetype):
1079-
mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream"
1095+
mimetype = mimetypes.guess_type(file_path)[0] or "application/octet-stream"
10801096

10811097
data: dict[str, typing.Any] = {
10821098
"name": name or stored_file_name,
10831099
"run": self._name,
10841100
"type": mimetype,
10851101
"storage": self._storage_id,
10861102
"category": category,
1087-
"size": (file_size := os.path.getsize(filename)),
1103+
"size": (file_size := os.path.getsize(file_path)),
10881104
"originalPath": os.path.abspath(
1089-
os.path.expanduser(os.path.expandvars(filename))
1105+
os.path.expanduser(os.path.expandvars(file_path))
10901106
),
1091-
"checksum": calculate_sha256(f"{filename}", True),
1107+
"checksum": calculate_sha256(f"{file_path}", True),
10921108
}
10931109

10941110
if not file_size:

simvue/serialization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def serialize_object(
6060
Returns
6161
-------
6262
Callable[[typing.Any], tuple[str, str]]
63-
the serializer to user
63+
the serializer to use
6464
"""
6565
module_name = data.__class__.__module__
6666
class_name = data.__class__.__name__

tests/refactor/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def setup_test_run(run: sv_run.Run, create_objects: bool, request: pytest.Fixtur
7979
"test_identifier": fix_use_id
8080
},
8181
"folder": f"/simvue_unit_testing/{fix_use_id}",
82-
"tags": ["simvue_client_unit_tests", request.node.name]
82+
"tags": ["simvue_client_unit_tests", request.node.name.replace("[", "_").replace("]", "_")]
8383
}
8484

8585
if os.environ.get("CI"):

0 commit comments

Comments
 (0)