pilot-platform-common 0.2.6__tar.gz → 0.2.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. {pilot-platform-common-0.2.6/pilot_platform_common.egg-info → pilot-platform-common-0.2.8}/PKG-INFO +1 -1
  2. pilot-platform-common-0.2.8/common/__init__.py +52 -0
  3. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/geid/__init__.py +5 -1
  4. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/geid/geid_client.py +1 -1
  5. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/jwt_handler/JWTHandler.py +1 -1
  6. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/jwt_handler/__init__.py +5 -1
  7. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/jwt_handler/jwt_handler_exception.py +1 -1
  8. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/lineage/__init__.py +5 -1
  9. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/lineage/entity_object.py +1 -2
  10. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/lineage/lineage_client.py +7 -13
  11. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/lineage/lineage_object.py +1 -1
  12. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/logger/__init__.py +5 -1
  13. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/logger/formatter.py +9 -5
  14. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/logger/logger_factory.py +1 -1
  15. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/models/__init__.py +1 -1
  16. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/models/config_center_policy.py +1 -1
  17. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/models/service_id_generator.py +1 -1
  18. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/object_storage_adaptor/__init__.py +9 -1
  19. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/object_storage_adaptor/base_client.py +1 -2
  20. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/object_storage_adaptor/boto3_admin_client.py +1 -1
  21. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/object_storage_adaptor/boto3_client.py +4 -4
  22. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/object_storage_adaptor/minio_policy_client.py +3 -3
  23. {pilot-platform-common-0.2.6/common → pilot-platform-common-0.2.8/common/permissions}/__init__.py +10 -9
  24. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/permissions/permissions.py +4 -4
  25. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/project/__init__.py +8 -1
  26. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/project/project_client.py +7 -3
  27. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/project/project_exceptions.py +1 -1
  28. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/vault/__init__.py +5 -1
  29. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/vault/vault_client.py +1 -1
  30. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/common/vault/vault_exception.py +1 -1
  31. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8/pilot_platform_common.egg-info}/PKG-INFO +1 -1
  32. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/pyproject.toml +2 -2
  33. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/setup.py +2 -3
  34. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/tests/__init__.py +1 -1
  35. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/tests/conftest.py +1 -1
  36. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/tests/test_formatter.py +1 -1
  37. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/tests/test_geid_client.py +1 -1
  38. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/tests/test_jwt_handler.py +1 -1
  39. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/tests/test_lineage_client.py +1 -2
  40. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/tests/test_logger_factory.py +1 -1
  41. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/tests/test_permissions.py +2 -2
  42. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/tests/test_project_client.py +1 -1
  43. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/tests/test_vault_client.py +1 -1
  44. pilot-platform-common-0.2.6/common/permissions/__init__.py +0 -16
  45. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/LICENSE +0 -0
  46. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/README.md +0 -0
  47. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/pilot_platform_common.egg-info/SOURCES.txt +0 -0
  48. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/pilot_platform_common.egg-info/dependency_links.txt +0 -0
  49. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/pilot_platform_common.egg-info/requires.txt +0 -0
  50. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/pilot_platform_common.egg-info/top_level.txt +0 -0
  51. {pilot-platform-common-0.2.6 → pilot-platform-common-0.2.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pilot-platform-common
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: Generates entity ID and connects with Vault (secret engine) to retrieve credentials
5
5
  Author: Indoc Research
6
6
  Author-email: etaylor@indocresearch.org
@@ -0,0 +1,52 @@
1
+ # Copyright (C) 2022 Indoc Research
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU Affero General Public License as
5
+ # published by the Free Software Foundation, either version 3 of the
6
+ # License, or (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU Affero General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Affero General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ from .geid import GEIDClient
17
+ from .jwt_handler import JWTHandler
18
+ from .lineage import LineageClient
19
+ from .logger import LoggerFactory
20
+ from .object_storage_adaptor import NotFoundError
21
+ from .object_storage_adaptor import TokenError
22
+ from .object_storage_adaptor import get_boto3_admin_client
23
+ from .object_storage_adaptor import get_boto3_client
24
+ from .object_storage_adaptor import get_minio_policy_client
25
+ from .permissions import get_project_role
26
+ from .permissions import has_file_permission
27
+ from .permissions import has_permission
28
+ from .project import ProjectClient
29
+ from .project import ProjectClientSync
30
+ from .project import ProjectException
31
+ from .project import ProjectNotFoundException
32
+ from .vault import VaultClient
33
+
34
+ __all__ = [
35
+ 'GEIDClient',
36
+ 'JWTHandler',
37
+ 'LineageClient',
38
+ 'LoggerFactory',
39
+ 'get_boto3_admin_client',
40
+ 'get_boto3_client',
41
+ 'get_minio_policy_client',
42
+ 'TokenError',
43
+ 'NotFoundError',
44
+ 'get_project_role',
45
+ 'has_file_permission',
46
+ 'has_permission',
47
+ 'ProjectClient',
48
+ 'ProjectClientSync',
49
+ 'ProjectException',
50
+ 'ProjectNotFoundException',
51
+ 'VaultClient',
52
+ ]
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -14,3 +14,7 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  from .geid_client import GEIDClient
17
+
18
+ __all__ = [
19
+ 'GEIDClient',
20
+ ]
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -14,3 +14,7 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  from .JWTHandler import JWTHandler
17
+
18
+ __all__ = [
19
+ 'JWTHandler',
20
+ ]
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -14,3 +14,7 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  from .lineage_client import LineageClient
17
+
18
+ __all__ = [
19
+ 'LineageClient',
20
+ ]
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -14,7 +14,6 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  import copy
17
- import time
18
17
 
19
18
 
20
19
  class FileDataAttribute:
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -95,7 +95,7 @@ class LineageClient:
95
95
  post_payload = {'entity': entity.json()}
96
96
 
97
97
  async with httpx.AsyncClient(verify=False) as client:
98
- self.logger.info('endpoint: ' + self.atlas_endpoint + '/api/atlas/v2/entity')
98
+ self.logger.info(f'endpoint: {self.atlas_endpoint}/api/atlas/v2/entity')
99
99
  self.logger.info('payload:')
100
100
  self.logger.info(post_payload)
101
101
 
@@ -129,7 +129,7 @@ class LineageClient:
129
129
 
130
130
  async with httpx.AsyncClient(verify=False) as client:
131
131
  response = await client.delete(
132
- self.atlas_endpoint + '/api/atlas/v2/entity/uniqueAttribute/type/{}'.format(entity_type),
132
+ self.atlas_endpoint + f'/api/atlas/v2/entity/uniqueAttribute/type/{entity_type}',
133
133
  params={'attr:item_id': _id},
134
134
  auth=(self.username, self.password),
135
135
  timeout=60,
@@ -160,7 +160,7 @@ class LineageClient:
160
160
 
161
161
  async with httpx.AsyncClient(verify=False) as client:
162
162
  response = await client.get(
163
- self.atlas_endpoint + '/api/atlas/v2/lineage/uniqueAttribute/type/{}'.format(entity_type),
163
+ self.atlas_endpoint + f'/api/atlas/v2/lineage/uniqueAttribute/type/{entity_type}',
164
164
  params={'attr:item_id': _id, 'depth': 50, 'direction': direction},
165
165
  auth=(self.username, self.password),
166
166
  timeout=60,
@@ -184,7 +184,7 @@ class LineageClient:
184
184
  # then loop over each of entity to get the detail attribute
185
185
  for atlas_guid in res['guidEntityMap']:
186
186
  response = await client.get(
187
- self.atlas_endpoint + '/api/atlas/v2/entity/guid/{}'.format(atlas_guid),
187
+ self.atlas_endpoint + f'/api/atlas/v2/entity/guid/{atlas_guid}',
188
188
  auth=(self.username, self.password),
189
189
  timeout=60,
190
190
  )
@@ -228,13 +228,7 @@ class LineageClient:
228
228
  - dict
229
229
  """
230
230
 
231
- name = '{}:{}:{}:to:{}@{}'.format(
232
- project_code,
233
- pipeline_name,
234
- input_name,
235
- output_name,
236
- created_time,
237
- )
231
+ name = f'{project_code}:{pipeline_name}:{input_name}:to:{output_name}@{created_time}'
238
232
 
239
233
  # NOTE: the id is the uuid in metadata service NOT the guid in Atlas
240
234
  lineage_attirbute = LineageAttirbute(name, entity_type, input_id, entity_type, output_id, description)
@@ -242,7 +236,7 @@ class LineageClient:
242
236
  atlas_post_form_json = {'entities': [lineage.json()]}
243
237
 
244
238
  async with httpx.AsyncClient(verify=False) as client:
245
- self.logger.info('endpoint: ' + self.atlas_endpoint + '/api/atlas/v2/entity')
239
+ self.logger.info(f'endpoint: {self.atlas_endpoint}/api/atlas/v2/entity')
246
240
  self.logger.info('payload:')
247
241
  self.logger.info(atlas_post_form_json)
248
242
 
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -14,3 +14,7 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  from .logger_factory import LoggerFactory
17
+
18
+ __all__ = [
19
+ 'LoggerFactory',
20
+ ]
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -14,7 +14,6 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  import os
17
- from functools import lru_cache
18
17
  from logging import LogRecord
19
18
  from typing import Any
20
19
  from typing import Dict
@@ -25,13 +24,18 @@ from pythonjsonlogger import jsonlogger
25
24
  class CustomJsonFormatter(jsonlogger.JsonFormatter):
26
25
  """Custom formatter to format logging records as json strings."""
27
26
 
28
- @lru_cache(1)
27
+ def __init__(self, *args: Any, **kwds: Any) -> None:
28
+ super().__init__(*args, **kwds)
29
+
30
+ self.namespace = None
31
+
29
32
  def get_namespace(self) -> str:
30
33
  """Get namespace for current service."""
31
34
 
32
- namespace = os.environ.get('namespace', 'unknown')
35
+ if self.namespace is None:
36
+ self.namespace = os.environ.get('namespace', 'unknown')
33
37
 
34
- return namespace
38
+ return self.namespace
35
39
 
36
40
  def add_fields(self, log_record: Dict[str, Any], record: LogRecord, message_dict: Dict[str, Any]) -> None:
37
41
  """Add custom fields into the log record."""
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,3 +18,11 @@ from .boto3_client import TokenError
18
18
  from .boto3_client import get_boto3_client
19
19
  from .minio_policy_client import NotFoundError
20
20
  from .minio_policy_client import get_minio_policy_client
21
+
22
+ __all__ = [
23
+ 'get_boto3_admin_client',
24
+ 'get_boto3_client',
25
+ 'get_minio_policy_client',
26
+ 'TokenError',
27
+ 'NotFoundError',
28
+ ]
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,7 +13,6 @@
13
13
  # You should have received a copy of the GNU Affero General Public License
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
-
17
16
  from logging import DEBUG
18
17
  from logging import ERROR
19
18
 
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -149,9 +149,9 @@ class Boto3Client(BaseClient):
149
149
  )
150
150
 
151
151
  if result.status_code == 400:
152
- raise TokenError('Get temp token with %s error: %s' % (result.status_code, result.text))
152
+ raise TokenError(f'Get temp token with {result.status_code} error: {result.text}')
153
153
  elif result.status_code != 200:
154
- raise Exception('Get temp token with %s error: %s' % (result.status_code, result.text))
154
+ raise Exception(f'Get temp token with {result.status_code} error: {result.text}')
155
155
 
156
156
  except Exception as e:
157
157
  error_msg = str(e)
@@ -368,7 +368,7 @@ class Boto3Client(BaseClient):
368
368
  res = await client.put(presigned_url, data=content, timeout=60)
369
369
 
370
370
  if res.status_code != 200:
371
- error_msg = 'Fail to upload the chunck %s: %s' % (part_number, str(res.text))
371
+ error_msg = f'Fail to upload the chunk {part_number}: {str(res.text)}'
372
372
  self.logger.error(error_msg)
373
373
  raise Exception(error_msg)
374
374
 
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -141,7 +141,7 @@ class MinioPolicyClient(Minio):
141
141
  )
142
142
 
143
143
  if response.status_code == 404:
144
- error_msg = 'Policy %s does not exist' % policy_name
144
+ error_msg = f'Policy {policy_name} does not exist'
145
145
  self.logger.error(error_msg)
146
146
  raise NotFoundError(error_msg)
147
147
  elif response.status_code != 200:
@@ -189,7 +189,7 @@ class MinioPolicyClient(Minio):
189
189
  )
190
190
 
191
191
  if response.status_code == 404:
192
- error_msg = 'Policy %s does not exist' % policy_name
192
+ error_msg = f'Policy {policy_name} does not exist'
193
193
  self.logger.error(error_msg)
194
194
  raise NotFoundError(error_msg)
195
195
  elif response.status_code != 200:
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,11 +13,12 @@
13
13
  # You should have received a copy of the GNU Affero General Public License
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
- from .geid import *
17
- from .jwt_handler import *
18
- from .lineage import *
19
- from .logger import *
20
- from .object_storage_adaptor import *
21
- from .project import *
22
- from .vault import *
23
- from .permissions import *
16
+ from .permissions import get_project_role
17
+ from .permissions import has_file_permission
18
+ from .permissions import has_permission
19
+
20
+ __all__ = [
21
+ 'get_project_role',
22
+ 'has_file_permission',
23
+ 'has_permission',
24
+ ]
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -79,10 +79,10 @@ async def has_file_permission(auth_url, file_entity: dict, operation: str, curre
79
79
 
80
80
  zone = 'greenroom' if file_entity['zone'] == 0 else 'core'
81
81
 
82
- if not file_entity.get('archived'):
83
- path_for_permissions = 'parent_path'
84
- else:
82
+ if file_entity.get('status') == 'ARCHIVED':
85
83
  path_for_permissions = 'restore_path'
84
+ else:
85
+ path_for_permissions = 'parent_path'
86
86
  root_folder = file_entity[path_for_permissions].split('/')[0]
87
87
 
88
88
  if root_folder != username:
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,3 +17,10 @@ from .project_client import ProjectClient
17
17
  from .project_client import ProjectClientSync
18
18
  from .project_exceptions import ProjectException
19
19
  from .project_exceptions import ProjectNotFoundException
20
+
21
+ __all__ = [
22
+ 'ProjectClient',
23
+ 'ProjectClientSync',
24
+ 'ProjectException',
25
+ 'ProjectNotFoundException',
26
+ ]
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -153,7 +153,7 @@ class ProjectClient(object):
153
153
  result['result'] = [self.project_object(item, self) for item in response.json()['result']]
154
154
  return result
155
155
 
156
- async def get(self, id='', code=''):
156
+ async def get(self, id='', code=''): # noqa: A002
157
157
  await self.connect_redis()
158
158
  project_id = ''
159
159
  if id:
@@ -182,7 +182,11 @@ class ProjectClient(object):
182
182
  logger.error(f"Couldn't connect to redis, skipping cache: {self.redis}")
183
183
  return self.project_object(response.json(), self)
184
184
 
185
- async def create(self, code, name, description, image_url=None, tags=[], system_tags=[], is_discoverable=True):
185
+ async def create(self, code, name, description, image_url=None, tags=None, system_tags=None, is_discoverable=True):
186
+ if tags is None:
187
+ tags = []
188
+ if system_tags is None:
189
+ system_tags = []
186
190
  data = {
187
191
  'code': code,
188
192
  'name': name,
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -14,3 +14,7 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  from .vault_client import VaultClient
17
+
18
+ __all__ = [
19
+ 'VaultClient',
20
+ ]
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pilot-platform-common
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: Generates entity ID and connects with Vault (secret engine) to retrieve credentials
5
5
  Author: Indoc Research
6
6
  Author-email: etaylor@indocresearch.org
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "common"
3
- version = "0.2.6"
3
+ version = "0.2.8"
4
4
  description = ""
5
5
  authors = ["Indoc Research"]
6
6
  license = "AGPL-3.0"
@@ -21,7 +21,7 @@ cryptography = "39.0.0"
21
21
 
22
22
  [tool.poetry.dev-dependencies]
23
23
  pytest = "6.2.5"
24
- pytest-asyncio= "0.18.3"
24
+ pytest-asyncio = "0.18.3"
25
25
  testcontainers = "3.4.2"
26
26
  coverage = "5.3"
27
27
  faker = "9.8.0"
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,7 +13,6 @@
13
13
  # You should have received a copy of the GNU Affero General Public License
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
- # read the contents of your README file
17
16
  from pathlib import Path
18
17
 
19
18
  import setuptools
@@ -23,7 +22,7 @@ long_description = (this_directory / 'README.md').read_text()
23
22
 
24
23
  setuptools.setup(
25
24
  name='pilot-platform-common',
26
- version='0.2.6',
25
+ version='0.2.8',
27
26
  author='Indoc Research',
28
27
  author_email='etaylor@indocresearch.org',
29
28
  description='Generates entity ID and connects with Vault (secret engine) to retrieve credentials',
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -14,7 +14,6 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  import uuid
17
- from cgitb import text
18
17
  from logging import DEBUG
19
18
  from logging import ERROR
20
19
 
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -178,7 +178,7 @@ class TestFilePermissions:
178
178
  @pytest.mark.asyncio
179
179
  async def test_has_file_permission_archived(self, httpx_mock):
180
180
  file_data = {
181
- 'archived': True,
181
+ 'status': 'ARCHIVED',
182
182
  'restore_path': 'test',
183
183
  'zone': 'core',
184
184
  'container_code': 'test_project',
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3,7 +3,7 @@
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as
5
5
  # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
6
+ # License, or (at your option) any later version.
7
7
  #
8
8
  # This program is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -1,16 +0,0 @@
1
- # Copyright (C) 2022 Indoc Research
2
- #
3
- # This program is free software: you can redistribute it and/or modify
4
- # it under the terms of the GNU Affero General Public License as
5
- # published by the Free Software Foundation, either version 3 of the
6
- # License, or any later version.
7
- #
8
- # This program is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- # GNU Affero General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU Affero General Public License
14
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
-
16
- from .permissions import has_permission, has_file_permission, get_project_role