Skip to content

Commit fbd5a26

Browse files
authored
Merge pull request #834 from simvue-io/kzscisoft/829-offline-mode-invalid-names
🐛 Fix non-ascii names in offline mode
2 parents 7efd676 + f7a5c05 commit fbd5a26

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

simvue/factory/proxy/offline.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import time
77
import typing
88
import uuid
9+
import unicodedata
910
import randomname
1011

1112
from simvue.factory.proxy.base import SimvueBaseClass
@@ -65,6 +66,15 @@ def _mock_api_post(
6566
self._write_json(filename, data)
6667
return data
6768

69+
@staticmethod
70+
def _generate_random_name() -> str:
71+
"""Generates a random name with only valid ASCII characters."""
72+
return (
73+
unicodedata.normalize("NFKD", randomname.get_name())
74+
.encode("ascii", "ignore")
75+
.decode("ascii")
76+
)
77+
6878
@skip_if_failed("_aborted", "_suppress_errors", (None, None))
6979
def create_run(self, data) -> tuple[str, str | None]:
7080
"""
@@ -75,7 +85,7 @@ def create_run(self, data) -> tuple[str, str | None]:
7585
return (None, None)
7686

7787
if not self.name:
78-
self.name = randomname.get_name()
88+
self.name = self._generate_random_name()
7989

8090
try:
8191
os.makedirs(self._directory, exist_ok=True)

0 commit comments

Comments
 (0)