sumo-wrapper-python 1.4.0__tar.gz → 1.6.0__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.
- sumo_wrapper_python-1.6.0/.github/pull_request_template.md +15 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/PKG-INFO +1 -1
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo/wrapper/_auth_provider.py +13 -4
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo/wrapper/_decorators.py +8 -4
- sumo_wrapper_python-1.6.0/src/sumo/wrapper/_version.py +24 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo/wrapper/login.py +14 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo/wrapper/sumo_client.py +7 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo_wrapper_python.egg-info/PKG-INFO +1 -1
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo_wrapper_python.egg-info/SOURCES.txt +1 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/tests/test_sumo_thin_client.py +3 -4
- sumo_wrapper_python-1.4.0/src/sumo/wrapper/_version.py +0 -34
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/.github/workflows/build_docs.yaml +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/.github/workflows/linting.yml +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/.github/workflows/publish_release.yml +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/.github/workflows/pytest.yml +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/.gitignore +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/.pre-commit-config.yaml +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/.readthedocs.yaml +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/CONTRIBUTING.md +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/LICENSE +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/README.md +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/SECURITY.md +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/docs/Makefile +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/docs/_static/equinor-logo.png +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/docs/_static/equinor-logo2.jpg +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/docs/_static/equinor_logo.jpg +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/docs/_static/equinor_logo_only.jpg +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/docs/_templates/layout.html +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/docs/api.rst +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/docs/conf.py +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/docs/index.rst +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/docs/make.bat +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/docs/sumo-wrapper-python.rst +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/pyproject.toml +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/setup.cfg +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo/__init__.py +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo/wrapper/__init__.py +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo/wrapper/_blob_client.py +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo/wrapper/_logging.py +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo/wrapper/_retry_strategy.py +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo_wrapper_python.egg-info/dependency_links.txt +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo_wrapper_python.egg-info/entry_points.txt +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo_wrapper_python.egg-info/requires.txt +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/src/sumo_wrapper_python.egg-info/top_level.txt +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/tests/conftest.py +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/tests/testdata/case.yml +0 -0
- {sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/tests/testdata/surface.yml +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## Issue
|
|
2
|
+
_Link to the issue resolved by this PR._
|
|
3
|
+
|
|
4
|
+
## Description
|
|
5
|
+
_Description of the approach taken to solve the issue._
|
|
6
|
+
|
|
7
|
+
## How to test
|
|
8
|
+
_How to verify the changes._
|
|
9
|
+
|
|
10
|
+
## Checklist
|
|
11
|
+
- [ ] No redundant \`print()\` statements, commented-out code, or other remnants from the development 👀
|
|
12
|
+
- [ ] New/refactored code is following same conventions as the rest of the code base 🧬
|
|
13
|
+
- [ ] New/refactored code is tested ⚙
|
|
14
|
+
- [ ] Documentation has been updated 🧾
|
|
15
|
+
- [ ] Commits are semantic ✅
|
|
@@ -99,6 +99,9 @@ class AuthProvider:
|
|
|
99
99
|
get_token_path(self._resource_id, ".sharedkey", case_uuid)
|
|
100
100
|
)
|
|
101
101
|
|
|
102
|
+
def delete_token(self):
|
|
103
|
+
return False
|
|
104
|
+
|
|
102
105
|
pass
|
|
103
106
|
|
|
104
107
|
|
|
@@ -322,8 +325,8 @@ class AuthProviderDeviceCode(AuthProvider):
|
|
|
322
325
|
if "error" in flow:
|
|
323
326
|
print(
|
|
324
327
|
"\n\n \033[31m"
|
|
325
|
-
+ "Failed to initiate device-code login. Err: %s"
|
|
326
|
-
|
|
328
|
+
+ "Failed to initiate device-code login. Err: %s\033[0m"
|
|
329
|
+
% json.dumps(flow, indent=4)
|
|
327
330
|
)
|
|
328
331
|
return
|
|
329
332
|
flow["expires_at"] = (
|
|
@@ -400,9 +403,10 @@ class AuthProviderSumoToken(AuthProvider):
|
|
|
400
403
|
def __init__(self, resource_id, case_uuid=None):
|
|
401
404
|
super().__init__(resource_id)
|
|
402
405
|
protect_token_cache(resource_id, ".sharedkey", case_uuid)
|
|
403
|
-
token_path = get_token_path(resource_id, ".sharedkey", case_uuid)
|
|
404
|
-
with open(token_path, "r") as f:
|
|
406
|
+
self.token_path = get_token_path(resource_id, ".sharedkey", case_uuid)
|
|
407
|
+
with open(self.token_path, "r") as f:
|
|
405
408
|
self._token = f.readline().strip()
|
|
409
|
+
|
|
406
410
|
return
|
|
407
411
|
|
|
408
412
|
def get_token(self):
|
|
@@ -411,6 +415,11 @@ class AuthProviderSumoToken(AuthProvider):
|
|
|
411
415
|
def get_authorization(self):
|
|
412
416
|
return {"X-SUMO-Token": self._token}
|
|
413
417
|
|
|
418
|
+
def delete_token(self):
|
|
419
|
+
if os.path.exists(self.token_path):
|
|
420
|
+
os.unlink(self.token_path)
|
|
421
|
+
return True
|
|
422
|
+
|
|
414
423
|
|
|
415
424
|
@tn.retry(
|
|
416
425
|
retry=tn.retry_if_exception(_maybe_nfs_exception),
|
|
@@ -4,11 +4,13 @@ from functools import wraps
|
|
|
4
4
|
|
|
5
5
|
def raise_for_status(func):
|
|
6
6
|
@wraps(func)
|
|
7
|
-
def wrapper(*args, **kwargs):
|
|
7
|
+
def wrapper(self, *args, **kwargs):
|
|
8
8
|
# FIXME: in newer versions of httpx, raise_for_status() is chainable,
|
|
9
9
|
# so we could simply write
|
|
10
10
|
# return func(*args, **kwargs).raise_for_status()
|
|
11
|
-
response = func(*args, **kwargs)
|
|
11
|
+
response = func(self, *args, **kwargs)
|
|
12
|
+
if response.status_code == 401:
|
|
13
|
+
self._handle_invalid_shared_key()
|
|
12
14
|
response.raise_for_status()
|
|
13
15
|
return response
|
|
14
16
|
|
|
@@ -17,11 +19,13 @@ def raise_for_status(func):
|
|
|
17
19
|
|
|
18
20
|
def raise_for_status_async(func):
|
|
19
21
|
@wraps(func)
|
|
20
|
-
async def wrapper(*args, **kwargs):
|
|
22
|
+
async def wrapper(self, *args, **kwargs):
|
|
21
23
|
# FIXME: in newer versions of httpx, raise_for_status() is chainable,
|
|
22
24
|
# so we could simply write
|
|
23
25
|
# return func(*args, **kwargs).raise_for_status()
|
|
24
|
-
response = await func(*args, **kwargs)
|
|
26
|
+
response = await func(self, *args, **kwargs)
|
|
27
|
+
if response.status_code == 401:
|
|
28
|
+
self._handle_invalid_shared_key()
|
|
25
29
|
response.raise_for_status()
|
|
26
30
|
return response
|
|
27
31
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '1.6.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (1, 6, 0)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = 'gcfd9c4112'
|
|
@@ -8,6 +8,8 @@ logger.setLevel(level="CRITICAL")
|
|
|
8
8
|
|
|
9
9
|
modes = ["interactive", "devicecode", "silent"]
|
|
10
10
|
|
|
11
|
+
fmu_sumo_uploader_client_id = "a65dc4cc-3dec-43df-9599-e66d3abc4dca"
|
|
12
|
+
|
|
11
13
|
|
|
12
14
|
def get_parser() -> ArgumentParser:
|
|
13
15
|
parser = ArgumentParser(description="Login to Sumo on azure")
|
|
@@ -47,6 +49,16 @@ def get_parser() -> ArgumentParser:
|
|
|
47
49
|
help="Print access token",
|
|
48
50
|
)
|
|
49
51
|
|
|
52
|
+
parser.add_argument(
|
|
53
|
+
"-u",
|
|
54
|
+
"--uploader",
|
|
55
|
+
dest="client_id",
|
|
56
|
+
action="store_const",
|
|
57
|
+
const=fmu_sumo_uploader_client_id,
|
|
58
|
+
default=None,
|
|
59
|
+
help="Use fmu-sumo-uploader client registration",
|
|
60
|
+
)
|
|
61
|
+
|
|
50
62
|
return parser
|
|
51
63
|
|
|
52
64
|
|
|
@@ -54,6 +66,7 @@ def main():
|
|
|
54
66
|
args = get_parser().parse_args()
|
|
55
67
|
logger.setLevel(level=args.verbosity)
|
|
56
68
|
env = args.env
|
|
69
|
+
client_id = args.client_id
|
|
57
70
|
mode = args.mode
|
|
58
71
|
is_interactive = mode == "interactive"
|
|
59
72
|
is_devicecode = mode == "devicecode"
|
|
@@ -71,6 +84,7 @@ def main():
|
|
|
71
84
|
env,
|
|
72
85
|
interactive=is_interactive,
|
|
73
86
|
devicecode=is_devicecode,
|
|
87
|
+
client_id=client_id,
|
|
74
88
|
)
|
|
75
89
|
token = sumo.authenticate()
|
|
76
90
|
|
|
@@ -208,6 +208,13 @@ class SumoClient:
|
|
|
208
208
|
self._retry_strategy,
|
|
209
209
|
)
|
|
210
210
|
|
|
211
|
+
def _handle_invalid_shared_key(self):
|
|
212
|
+
"""Handle the invalid shared key by deleting it."""
|
|
213
|
+
if self.auth.delete_token():
|
|
214
|
+
print(
|
|
215
|
+
"Invalid shared key detected and deleted, run again to reset automatically"
|
|
216
|
+
)
|
|
217
|
+
|
|
211
218
|
@raise_for_status
|
|
212
219
|
def get(self, path: str, params: Optional[Dict] = None) -> httpx.Response:
|
|
213
220
|
"""Performs a GET-request to the Sumo API.
|
|
@@ -50,8 +50,7 @@ def _upload_child_level_json(conn, parent_id, json):
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
def _delete_object(conn, object_id):
|
|
53
|
-
response = conn.delete(f"/objects('{object_id}')")
|
|
54
|
-
|
|
53
|
+
response = conn.delete(f"/objects('{object_id}')")
|
|
55
54
|
return response
|
|
56
55
|
|
|
57
56
|
|
|
@@ -144,7 +143,7 @@ def test_upload_search_delete_ensemble_child(token):
|
|
|
144
143
|
|
|
145
144
|
# Delete Ensemble
|
|
146
145
|
result = _delete_object(conn=sumo_client, object_id=case_id)
|
|
147
|
-
assert result == "Accepted"
|
|
146
|
+
assert result.text == "Accepted."
|
|
148
147
|
|
|
149
148
|
sleep(40)
|
|
150
149
|
|
|
@@ -210,7 +209,7 @@ def test_upload_duplicate_ensemble(token):
|
|
|
210
209
|
# Delete Ensemble
|
|
211
210
|
sleep(5)
|
|
212
211
|
result = _delete_object(conn=conn, object_id=case_id1)
|
|
213
|
-
assert result == "Accepted"
|
|
212
|
+
assert result.text == "Accepted."
|
|
214
213
|
|
|
215
214
|
# Ugly: sumo-core has a cache for case objects, which has a
|
|
216
215
|
# time-to-live of 60 seconds. If there are multiple replicas
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# file generated by setuptools-scm
|
|
2
|
-
# don't change, don't track in version control
|
|
3
|
-
|
|
4
|
-
__all__ = [
|
|
5
|
-
"__version__",
|
|
6
|
-
"__version_tuple__",
|
|
7
|
-
"version",
|
|
8
|
-
"version_tuple",
|
|
9
|
-
"__commit_id__",
|
|
10
|
-
"commit_id",
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
TYPE_CHECKING = False
|
|
14
|
-
if TYPE_CHECKING:
|
|
15
|
-
from typing import Tuple
|
|
16
|
-
from typing import Union
|
|
17
|
-
|
|
18
|
-
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
-
COMMIT_ID = Union[str, None]
|
|
20
|
-
else:
|
|
21
|
-
VERSION_TUPLE = object
|
|
22
|
-
COMMIT_ID = object
|
|
23
|
-
|
|
24
|
-
version: str
|
|
25
|
-
__version__: str
|
|
26
|
-
__version_tuple__: VERSION_TUPLE
|
|
27
|
-
version_tuple: VERSION_TUPLE
|
|
28
|
-
commit_id: COMMIT_ID
|
|
29
|
-
__commit_id__: COMMIT_ID
|
|
30
|
-
|
|
31
|
-
__version__ = version = '1.4.0'
|
|
32
|
-
__version_tuple__ = version_tuple = (1, 4, 0)
|
|
33
|
-
|
|
34
|
-
__commit_id__ = commit_id = 'g8c4d4a4f8'
|
|
File without changes
|
|
File without changes
|
{sumo_wrapper_python-1.4.0 → sumo_wrapper_python-1.6.0}/.github/workflows/publish_release.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|