Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion simvue/factory/proxy/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import time
import typing
import uuid
import unicodedata
import randomname

from simvue.factory.proxy.base import SimvueBaseClass
Expand Down Expand Up @@ -65,6 +66,15 @@ def _mock_api_post(
self._write_json(filename, data)
return data

@staticmethod
def _generate_random_name() -> str:
"""Generates a random name with only valid ASCII characters."""
return (
unicodedata.normalize("NFKD", randomname.get_name())
.encode("ascii", "ignore")
.decode("ascii")
)

@skip_if_failed("_aborted", "_suppress_errors", (None, None))
def create_run(self, data) -> tuple[str, str | None]:
"""
Expand All @@ -75,7 +85,7 @@ def create_run(self, data) -> tuple[str, str | None]:
return (None, None)

if not self.name:
self.name = randomname.get_name()
self.name = self._generate_random_name()

try:
os.makedirs(self._directory, exist_ok=True)
Expand Down