From 934b5bf8081ff33b2916a63914a8d0f8be8f0ed1 Mon Sep 17 00:00:00 2001 From: Christopher Wood Date: Thu, 4 Nov 2021 14:11:25 -0400 Subject: [PATCH] Replace `str(uuid4())` with `uuid4().hex` Using `uuid4().hex` removes the dashes from the returned strings to make them more compact and easier to display. --- qiskit_experiments/database_service/db_analysis_result.py | 2 +- qiskit_experiments/database_service/db_experiment_data.py | 4 ++-- test/calibration/test_calibrations.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qiskit_experiments/database_service/db_analysis_result.py b/qiskit_experiments/database_service/db_analysis_result.py index 3ef001389d..08aae9a350 100644 --- a/qiskit_experiments/database_service/db_analysis_result.py +++ b/qiskit_experiments/database_service/db_analysis_result.py @@ -90,7 +90,7 @@ def __init__( """ # Data to be stored in DB. self._experiment_id = experiment_id - self._id = result_id or str(uuid.uuid4()) + self._id = result_id or uuid.uuid4().hex self._name = name self._value = copy.deepcopy(value) self._extra = copy.deepcopy(extra or {}) diff --git a/qiskit_experiments/database_service/db_experiment_data.py b/qiskit_experiments/database_service/db_experiment_data.py index 1abb154dde..69ed38c198 100644 --- a/qiskit_experiments/database_service/db_experiment_data.py +++ b/qiskit_experiments/database_service/db_experiment_data.py @@ -156,7 +156,7 @@ def __init__( self._auto_save = False self._set_service_from_backend(backend) - self._id = experiment_id or str(uuid.uuid4()) + self._id = experiment_id or uuid.uuid4().hex self._parent_id = parent_id self._type = experiment_type self._tags = tags or [] @@ -287,7 +287,7 @@ def add_analysis_callback(self, callback: Callable, **kwargs: Any): keywork arguments passed to this method. **kwargs: Keyword arguments to be passed to the callback function. """ - callback_id = uuid.uuid4() + callback_id = uuid.uuid4().hex self._callback_statuses[callback_id] = CallbackStatus(callback, kwargs=kwargs) # Wrap callback function to handle reporting status and catching diff --git a/test/calibration/test_calibrations.py b/test/calibration/test_calibrations.py index d55da9bb0f..bc7b52ac92 100644 --- a/test/calibration/test_calibrations.py +++ b/test/calibration/test_calibrations.py @@ -1302,7 +1302,7 @@ class TestSavingAndLoading(CrossResonanceTest): def setUp(self): """Setup the test.""" - self._prefix = str(uuid.uuid4()) + self._prefix = uuid.uuid4().hex super().setUp() def tearDown(self):