From 988e714672b2b8af4de3cfb7bb8a3f5156f1a4c4 Mon Sep 17 00:00:00 2001 From: Martin Beisel Date: Tue, 15 Mar 2022 18:15:16 +0100 Subject: [PATCH] codestyling --- app/database/minio_db.py | 7 +++---- app/utils/helper_functions.py | 16 +++++++--------- config.py | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/database/minio_db.py b/app/database/minio_db.py index 4982ab7..79a2ec2 100644 --- a/app/database/minio_db.py +++ b/app/database/minio_db.py @@ -20,7 +20,6 @@ TMPDIR = os.path.join(os.getcwd(), "tmp") - def check_if_bucket_exists(bucketname): # Make QPU bucket if not exist. found = client.bucket_exists(bucketname) @@ -30,6 +29,7 @@ def check_if_bucket_exists(bucketname): else: print("Bucket '" + bucketname + "' already exists") + def store_matrix_object_in_db(matrix, qpu: str, matrix_type: MatrixType, **kwargs): """ @@ -73,7 +73,6 @@ def store_matrix_object_in_db(matrix, qpu: str, matrix_type: MatrixType, **kwarg raise - def load_matrix_object_from_db(qpu, matrix_type: MatrixType, **kwargs): """ @@ -178,7 +177,6 @@ def load_mitigator_object_from_db_by_filename( return matrix, metadata - def get_obj_metadata(obj): metadata = {"name": obj.object_name} for key, value in obj.metadata.items(): @@ -208,7 +206,6 @@ def get_obj_metadata(obj): print(res) - ######################################################## # # # LEGACY FEATURE - RATHER USE OBJECT INSTEAD # @@ -217,6 +214,7 @@ def get_obj_metadata(obj): from app.utils.helper_functions import deprecated + @deprecated def store_matrix_file_in_db(matrix, qpu: str, matrix_type: MatrixType, **kwargs): """ @@ -254,6 +252,7 @@ def store_matrix_file_in_db(matrix, qpu: str, matrix_type: MatrixType, **kwargs) os.remove(source_filepath) return filename + @deprecated def load_matrix_file_from_db(qpu, matrix_type: MatrixType, **kwargs): """ diff --git a/app/utils/helper_functions.py b/app/utils/helper_functions.py index 3b14391..e2edba9 100644 --- a/app/utils/helper_functions.py +++ b/app/utils/helper_functions.py @@ -67,12 +67,11 @@ def countsdict_to_array(dict, qubits, qubits_mm): print(vector) - import functools import inspect import warnings -string_types = (type(b''), type(u'')) +string_types = (type(b""), type(u"")) def deprecated(reason): @@ -101,13 +100,13 @@ def decorator(func1): @functools.wraps(func1) def new_func1(*args, **kwargs): - warnings.simplefilter('always', DeprecationWarning) + warnings.simplefilter("always", DeprecationWarning) warnings.warn( fmt1.format(name=func1.__name__, reason=reason), category=DeprecationWarning, - stacklevel=2 + stacklevel=2, ) - warnings.simplefilter('default', DeprecationWarning) + warnings.simplefilter("default", DeprecationWarning) return func1(*args, **kwargs) return new_func1 @@ -133,13 +132,13 @@ def new_func1(*args, **kwargs): @functools.wraps(func2) def new_func2(*args, **kwargs): - warnings.simplefilter('always', DeprecationWarning) + warnings.simplefilter("always", DeprecationWarning) warnings.warn( fmt2.format(name=func2.__name__), category=DeprecationWarning, - stacklevel=2 + stacklevel=2, ) - warnings.simplefilter('default', DeprecationWarning) + warnings.simplefilter("default", DeprecationWarning) return func2(*args, **kwargs) return new_func2 @@ -148,7 +147,6 @@ def new_func2(*args, **kwargs): raise TypeError(repr(type(reason))) - if __name__ == "__main__": dict = { "111": 129, diff --git a/config.py b/config.py index fb62da7..4b3b0d2 100644 --- a/config.py +++ b/config.py @@ -20,7 +20,7 @@ class Config: "license": {"name": "Apache v2 License"}, } - MINIO_ENDPOINT = os.environ.get('MINIO_URL') or "localhost:9000" + MINIO_ENDPOINT = os.environ.get("MINIO_URL") or "localhost:9000" MINIO_USER = "minio" MINIO_PASSWORD = "minio123" MINIO_SECURITY = False