From ec7697b30fa6f9bc804973fb128688d421bd70da Mon Sep 17 00:00:00 2001 From: Anish Umesh Date: Mon, 13 Mar 2023 16:18:34 +0100 Subject: [PATCH 1/7] sqlalchemy version fix --- backend/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/setup.py b/backend/setup.py index c782456..252524e 100644 --- a/backend/setup.py +++ b/backend/setup.py @@ -75,7 +75,7 @@ "streaming_form_data", "psutil", "uvicorn", - "sqlalchemy>=1.4.0", + "sqlalchemy<=1.4.46", # Postgres Driver "psycopg2", # Generates concise, unambiguous, URL-safe UUIDs. From 238efae21b41430e6406c3075d69724f5da8bdac Mon Sep 17 00:00:00 2001 From: Anish Umesh Date: Mon, 13 Mar 2023 16:29:10 +0100 Subject: [PATCH 2/7] add dependancy --- backend/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/setup.py b/backend/setup.py index 252524e..4a64a62 100644 --- a/backend/setup.py +++ b/backend/setup.py @@ -75,6 +75,7 @@ "streaming_form_data", "psutil", "uvicorn", + "colorama", "sqlalchemy<=1.4.46", # Postgres Driver "psycopg2", From 7e0274ccf92fed375bf1896e208e001d17c1aace Mon Sep 17 00:00:00 2001 From: Anish Umesh Date: Wed, 15 Mar 2023 14:13:11 +0100 Subject: [PATCH 3/7] flake8 fix --- backend/setup.cfg | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/setup.cfg b/backend/setup.cfg index 4aec9e2..d296cb2 100644 --- a/backend/setup.cfg +++ b/backend/setup.cfg @@ -7,11 +7,15 @@ universal = false [flake8] ignore = - E203, # space before : (needed for how black formats slicing) + # space before : (needed for how black formats slicing) + E203, # E266, # too many leading '#' for block comment - E501, # line too long - E731, # do not assign a lambda expression, use a def - W503, # line break before binary operator + # line too long + E501, + # do not assign a lambda expression, use a def + E731, + # line break before binary operator + W503, max-line-length = 88 # select = B,C,E,F,W,T4,B9 # max-complexity = 18 From ee0d8f1ddd99a63062d5faa6ef4da7e2ee373b7a Mon Sep 17 00:00:00 2001 From: Anish Umesh Date: Wed, 15 Mar 2023 14:24:45 +0100 Subject: [PATCH 4/7] remove space --- backend/setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/setup.cfg b/backend/setup.cfg index d296cb2..87b54f0 100644 --- a/backend/setup.cfg +++ b/backend/setup.cfg @@ -8,7 +8,7 @@ universal = false [flake8] ignore = # space before : (needed for how black formats slicing) - E203, + E203, # E266, # too many leading '#' for block comment # line too long E501, From 1eb2ce10f63b7f8a41968f09895e7533ab1bd4fe Mon Sep 17 00:00:00 2001 From: Anish Umesh Date: Thu, 16 Mar 2023 10:18:42 +0100 Subject: [PATCH 5/7] change dependency order --- backend/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/setup.py b/backend/setup.py index 9fb2b99..a959148 100644 --- a/backend/setup.py +++ b/backend/setup.py @@ -77,7 +77,6 @@ "streaming_form_data", "psutil", "uvicorn", - "colorama", "sqlalchemy<=1.4.46", # Postgres Driver "psycopg2", @@ -109,6 +108,7 @@ "wheel", "twine", "flake8", + "colorama", "pytest", "pytest-mock", "pytest-cov", From 696ec8d95bcae7a944233460488c794cacb0cd94 Mon Sep 17 00:00:00 2001 From: Anish Umesh Date: Thu, 16 Mar 2023 10:29:29 +0100 Subject: [PATCH 6/7] fix --- backend/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/setup.py b/backend/setup.py index a959148..9fb2b99 100644 --- a/backend/setup.py +++ b/backend/setup.py @@ -77,6 +77,7 @@ "streaming_form_data", "psutil", "uvicorn", + "colorama", "sqlalchemy<=1.4.46", # Postgres Driver "psycopg2", @@ -108,7 +109,6 @@ "wheel", "twine", "flake8", - "colorama", "pytest", "pytest-mock", "pytest-cov", From 50ddf166f8c75b12fb057deb52df49e4354d9b1c Mon Sep 17 00:00:00 2001 From: Anish Umesh Date: Mon, 20 Mar 2023 10:38:26 +0100 Subject: [PATCH 7/7] black format --- backend/src/contaxy/clients/file.py | 2 -- backend/src/contaxy/managers/auth.py | 2 -- backend/src/contaxy/managers/deployment/kube_utils.py | 1 - backend/src/contaxy/managers/deployment/kubernetes.py | 2 -- backend/src/contaxy/managers/file/azure_blob.py | 2 -- backend/src/contaxy/managers/file/minio.py | 1 - backend/src/contaxy/utils/file_utils.py | 1 - backend/tests/test_file_operations.py | 1 - backend/tests/test_file_utils.py | 3 --- backend/tests/test_json_db_operations.py | 3 --- 10 files changed, 18 deletions(-) diff --git a/backend/src/contaxy/clients/file.py b/backend/src/contaxy/clients/file.py index beb4699..9e47242 100644 --- a/backend/src/contaxy/clients/file.py +++ b/backend/src/contaxy/clients/file.py @@ -24,7 +24,6 @@ def list_files( prefix: Optional[str] = None, request_kwargs: Dict = {}, ) -> List[File]: - query_params: Dict = { "recursive": recursive, "include_versions": include_versions, @@ -47,7 +46,6 @@ def get_file_metadata( version: Optional[str] = None, request_kwargs: Dict = {}, ) -> File: - query_params: Dict = {} if version: query_params.update({"version": version}) diff --git a/backend/src/contaxy/managers/auth.py b/backend/src/contaxy/managers/auth.py index 8aaa1a7..dfe02e6 100644 --- a/backend/src/contaxy/managers/auth.py +++ b/backend/src/contaxy/managers/auth.py @@ -161,7 +161,6 @@ def _create_session_token( scopes: List[str], expiry_minutes: Optional[timedelta] = None, ) -> str: - if expiry_minutes: expire = datetime.now(timezone.utc) + expiry_minutes else: @@ -339,7 +338,6 @@ def _verify_access_via_db( ) -> AuthorizedAccess: scope_grants_access = False for scope in token.scopes: - if not auth_utils.is_valid_permission(scope): logger.warning(f"The token scope ({scope}) is not valid.") continue diff --git a/backend/src/contaxy/managers/deployment/kube_utils.py b/backend/src/contaxy/managers/deployment/kube_utils.py index e8281f3..d9d63a9 100644 --- a/backend/src/contaxy/managers/deployment/kube_utils.py +++ b/backend/src/contaxy/managers/deployment/kube_utils.py @@ -160,7 +160,6 @@ def build_kube_service_config( service_ports: Dict[str, V1ServicePort] = {} if service.endpoints: for endpoint in service.endpoints: - # An endpoint can be in the form of one of the examples ["8080", "9001/webapp/ui", "9002b"]. See the Contaxy endpoint docs for more information. port_number = endpoint.split("/")[0].replace("b", "") diff --git a/backend/src/contaxy/managers/deployment/kubernetes.py b/backend/src/contaxy/managers/deployment/kubernetes.py index 6dfb8a4..cf3e1c8 100644 --- a/backend/src/contaxy/managers/deployment/kubernetes.py +++ b/backend/src/contaxy/managers/deployment/kubernetes.py @@ -109,7 +109,6 @@ def deploy_service( action_id: Optional[str] = None, wait: bool = False, ) -> Service: - kube_service_config = build_kube_service_config( service=service, project_id=project_id, @@ -249,7 +248,6 @@ def delete_service( delete_volumes: bool = False, retries: int = 0, ) -> None: - try: self.core_api.delete_namespaced_service( name=service_id, diff --git a/backend/src/contaxy/managers/file/azure_blob.py b/backend/src/contaxy/managers/file/azure_blob.py index a4f75c6..3141ff6 100644 --- a/backend/src/contaxy/managers/file/azure_blob.py +++ b/backend/src/contaxy/managers/file/azure_blob.py @@ -526,7 +526,6 @@ def _load_file_data_from_azure( prefix: Optional[str] = None, include_version: Optional[bool] = None, ) -> Tuple[List[File], List[str]]: - file_data: List[File] = [] db_keys: List[str] = [] file_versions: Dict[str, List[str]] = {} @@ -559,7 +558,6 @@ def _load_file_data_from_azure( def _enrich_data_from_db( self, project_id: str, file_data: List[File], document_keys: List[str] ) -> Tuple[List[File], List[Tuple[str, str]]]: - json_docs = self.json_db_manager.list_json_documents( project_id, self.DOC_COLLECTION_NAME, keys=document_keys ) diff --git a/backend/src/contaxy/managers/file/minio.py b/backend/src/contaxy/managers/file/minio.py index 0b82575..38957ac 100644 --- a/backend/src/contaxy/managers/file/minio.py +++ b/backend/src/contaxy/managers/file/minio.py @@ -538,7 +538,6 @@ def _load_file_data_from_s3( def _enrich_data_from_db( self, project_id: str, file_data: List[File], document_keys: List[str] ) -> Tuple[List[File], List[Tuple[str, str]]]: - json_docs = self._json_db_manager.list_json_documents( project_id, self.DOC_COLLECTION_NAME, keys=document_keys ) diff --git a/backend/src/contaxy/utils/file_utils.py b/backend/src/contaxy/utils/file_utils.py index f49369c..628c317 100644 --- a/backend/src/contaxy/utils/file_utils.py +++ b/backend/src/contaxy/utils/file_utils.py @@ -98,7 +98,6 @@ def hash(self) -> str: return "" def read(self, size: int = -1) -> bytes: - if size == 0: return b"" diff --git a/backend/tests/test_file_operations.py b/backend/tests/test_file_operations.py index caad420..4329830 100644 --- a/backend/tests/test_file_operations.py +++ b/backend/tests/test_file_operations.py @@ -250,7 +250,6 @@ def test_download_file(self) -> None: assert version_1.md5_hash == hash.hexdigest() def test_delete_file(self) -> None: - # Test - File does not exist self.file_manager.delete_file(self.project_id, "invalid-key") diff --git a/backend/tests/test_file_utils.py b/backend/tests/test_file_utils.py index fadedd7..cc601be 100644 --- a/backend/tests/test_file_utils.py +++ b/backend/tests/test_file_utils.py @@ -23,7 +23,6 @@ def metadata() -> dict: @pytest.fixture() def multipart_data(metadata: dict) -> dict: - stream = b'------WebKitFormBoundaryr1D8WqBUjhPTDqlM\r\nContent-Disposition: form-data; name="file"; filename="test.csv"\r\nContent-Type: text/csv\r\n\r\n' stream += 5000 * b"foo;bar\n" stream += b"\r\n------WebKitFormBoundaryr1D8WqBUjhPTDqlM--\r\n" @@ -42,7 +41,6 @@ def file_data(metadata: dict) -> dict: @pytest.mark.unit class TestFormMultipartStream: def test_multipart_stream(self, multipart_data: dict) -> None: - file_stream = multipart_data.get("stream") assert file_stream @@ -66,7 +64,6 @@ def test_multipart_stream(self, multipart_data: dict) -> None: @pytest.mark.unit class TestSyncFromAsyncGenerator: def test_iteration(self) -> None: - data = list(range(5)) async def iterate(data: list) -> AsyncGenerator: diff --git a/backend/tests/test_json_db_operations.py b/backend/tests/test_json_db_operations.py index 0ad541f..f10a042 100644 --- a/backend/tests/test_json_db_operations.py +++ b/backend/tests/test_json_db_operations.py @@ -125,7 +125,6 @@ def test_delete_json_document(self) -> None: ) def test_update_json_document(self) -> None: - original_dict = { "title": "Goodbye!", "author": {"givenName": "John", "familyName": "Doe"}, @@ -184,7 +183,6 @@ def test_update_json_document(self) -> None: ) def test_list_json_documents(self) -> None: - collection_id = self.COLLECTTION data = [ @@ -262,7 +260,6 @@ def test_list_json_documents(self) -> None: ) def test_list_json_documents_by_key(self) -> None: - docs = [] db_keys = [] for i in range(3):