kleinkram 0.40.0.dev20250225150133__py3-none-any.whl → 0.40.0.dev20250228081255__py3-none-any.whl
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.
Potentially problematic release.
This version of kleinkram might be problematic. Click here for more details.
- kleinkram/api/client.py +3 -1
- kleinkram/config.py +20 -4
- kleinkram/utils.py +1 -4
- {kleinkram-0.40.0.dev20250225150133.dist-info → kleinkram-0.40.0.dev20250228081255.dist-info}/METADATA +1 -1
- {kleinkram-0.40.0.dev20250225150133.dist-info → kleinkram-0.40.0.dev20250228081255.dist-info}/RECORD +9 -9
- {kleinkram-0.40.0.dev20250225150133.dist-info → kleinkram-0.40.0.dev20250228081255.dist-info}/WHEEL +1 -1
- tests/test_config.py +19 -1
- {kleinkram-0.40.0.dev20250225150133.dist-info → kleinkram-0.40.0.dev20250228081255.dist-info}/entry_points.txt +0 -0
- {kleinkram-0.40.0.dev20250225150133.dist-info → kleinkram-0.40.0.dev20250228081255.dist-info}/top_level.txt +0 -0
kleinkram/api/client.py
CHANGED
|
@@ -148,7 +148,9 @@ class AuthenticatedClient(httpx.Client):
|
|
|
148
148
|
raise NotAuthenticated
|
|
149
149
|
|
|
150
150
|
logger.info(f"retrying request {method} {full_url}")
|
|
151
|
-
resp = super().request(
|
|
151
|
+
resp = super().request(
|
|
152
|
+
method, full_url, params=httpx_params, *args, **kwargs
|
|
153
|
+
)
|
|
152
154
|
logger.info(f"got response {resp}")
|
|
153
155
|
return resp
|
|
154
156
|
else:
|
kleinkram/config.py
CHANGED
|
@@ -24,6 +24,7 @@ from rich.text import Text
|
|
|
24
24
|
|
|
25
25
|
from kleinkram._version import __local__
|
|
26
26
|
from kleinkram._version import __version__
|
|
27
|
+
from kleinkram.utils import format_traceback
|
|
27
28
|
|
|
28
29
|
logger = logging.getLogger(__name__)
|
|
29
30
|
|
|
@@ -75,8 +76,8 @@ def get_env() -> Environment:
|
|
|
75
76
|
|
|
76
77
|
|
|
77
78
|
ACTION_API_KEY = "KLEINKRAM_API_KEY"
|
|
78
|
-
ACTION_API = "
|
|
79
|
-
ACTION_S3 = "
|
|
79
|
+
ACTION_API = "KLEINKRAM_API_ENDPOINT"
|
|
80
|
+
ACTION_S3 = "KLEINKRAM_S3_ENDPOINT"
|
|
80
81
|
|
|
81
82
|
|
|
82
83
|
def _get_endpoint_from_action_env_vars() -> Optional[Endpoint]:
|
|
@@ -167,13 +168,28 @@ def _config_from_dict(dct: Dict[str, Any]) -> Config:
|
|
|
167
168
|
)
|
|
168
169
|
|
|
169
170
|
|
|
170
|
-
def
|
|
171
|
-
|
|
171
|
+
def _safe_config_write(
|
|
172
|
+
config: Config, path: Path, tmp_dir: Optional[Path] = None
|
|
173
|
+
) -> None:
|
|
174
|
+
fd, temp_path = tempfile.mkstemp(dir=tmp_dir)
|
|
172
175
|
with os.fdopen(fd, "w") as f:
|
|
173
176
|
json.dump(_config_to_dict(config), f)
|
|
174
177
|
os.replace(temp_path, path)
|
|
175
178
|
|
|
176
179
|
|
|
180
|
+
def _unsafe_config_write(config: Config, path: Path) -> None:
|
|
181
|
+
with open(path, "w") as f:
|
|
182
|
+
json.dump(_config_to_dict(config), f)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def save_config(config: Config, path: Path = CONFIG_PATH) -> None:
|
|
186
|
+
try:
|
|
187
|
+
_safe_config_write(config, path)
|
|
188
|
+
except Exception as e:
|
|
189
|
+
logger.warning(f"failed to safe write config {format_traceback(e)}")
|
|
190
|
+
_unsafe_config_write(config, path)
|
|
191
|
+
|
|
192
|
+
|
|
177
193
|
def _load_config_if_compatible(path: Path) -> Optional[Config]:
|
|
178
194
|
if not path.exists():
|
|
179
195
|
return None
|
kleinkram/utils.py
CHANGED
|
@@ -40,10 +40,7 @@ def file_paths_from_files(
|
|
|
40
40
|
determines the destinations for a sequence of `File` objects,
|
|
41
41
|
possibly nested by project and mission
|
|
42
42
|
"""
|
|
43
|
-
if (
|
|
44
|
-
len(set([(file.project_id, file.mission_id) for file in files])) > 1
|
|
45
|
-
and not allow_nested
|
|
46
|
-
):
|
|
43
|
+
if len(set([file.mission_id for file in files])) > 1 and not allow_nested:
|
|
47
44
|
raise ValueError("files from multiple missions were selected")
|
|
48
45
|
elif not allow_nested:
|
|
49
46
|
return {dest / file.name: file for file in files}
|
{kleinkram-0.40.0.dev20250225150133.dist-info → kleinkram-0.40.0.dev20250228081255.dist-info}/RECORD
RENAMED
|
@@ -2,7 +2,7 @@ kleinkram/__init__.py,sha256=xIJqTJw2kbCGryGlCeAdpmtR1FTxmrW1MklUNQEaj74,1061
|
|
|
2
2
|
kleinkram/__main__.py,sha256=B9RiZxfO4jpCmWPUHyKJ7_EoZlEG4sPpH-nz7T_YhhQ,125
|
|
3
3
|
kleinkram/_version.py,sha256=QYJyRTcqFcJj4qWYpqs7WcoOP6jxDMqyvxLY-cD6KcE,129
|
|
4
4
|
kleinkram/auth.py,sha256=XD_rHOyJmYYfO7QJf3TLYH5qXA22gXGWi7PT3jujlVs,2968
|
|
5
|
-
kleinkram/config.py,sha256=
|
|
5
|
+
kleinkram/config.py,sha256=_ZfOSfEZaK8ZbgoNRZL2h3ozZfxHnKqmLJ9mUIYOxBU,7413
|
|
6
6
|
kleinkram/core.py,sha256=Q7OYIKPN9K6kxf9Eq7r5XRHPJ3RtT7SBZp_3_CS8yuY,8429
|
|
7
7
|
kleinkram/errors.py,sha256=4mygNxkf6IBgaiRWY95qu0v6z4TAXA3G6CUcXC9FU3s,772
|
|
8
8
|
kleinkram/main.py,sha256=BTE0mZN__xd46wBhFi6iBlK9eGGQvJ1LdUMsbnysLi0,172
|
|
@@ -10,10 +10,10 @@ kleinkram/models.py,sha256=8nJlPrKVLSmehspeuQSFV6nUo76JzehUn6KIZYH1xy4,1832
|
|
|
10
10
|
kleinkram/printing.py,sha256=fpkJFeVp5pzZ_cZY6nzYDV_qDFWHKHxiW-DaH2PPNeY,12160
|
|
11
11
|
kleinkram/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
kleinkram/types.py,sha256=nfDjj8TB1Jn5vqO0Xg6qhLOuKom9DDhe62BrngqnVGM,185
|
|
13
|
-
kleinkram/utils.py,sha256=
|
|
13
|
+
kleinkram/utils.py,sha256=fFQsq5isLjDC2Z-XUTiJzz30Wt9rFUi4391WXstusG0,6221
|
|
14
14
|
kleinkram/wrappers.py,sha256=4xXU43eNnvMG2sssU330MmTLSSRdurOpnZ-zNGOGmt0,11342
|
|
15
15
|
kleinkram/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
-
kleinkram/api/client.py,sha256=
|
|
16
|
+
kleinkram/api/client.py,sha256=1mQuguyYM3ghrADTlivQi9ybWjJzlb9emto5rPtJRkM,5112
|
|
17
17
|
kleinkram/api/deser.py,sha256=xRpYUFKZ0Luoo7XyAtYblJvprmpjNSZOiFVnFKmOzcM,4819
|
|
18
18
|
kleinkram/api/file_transfer.py,sha256=3wNlVQdjnRtxOzih5HhCTF18xPbYClFIDxCqbwkLl6c,12985
|
|
19
19
|
kleinkram/api/pagination.py,sha256=P_zPsBKlMWkmAv-YfUNHaGW-XLB_4U8BDMrKyiDFIXk,1370
|
|
@@ -34,7 +34,7 @@ testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
34
34
|
testing/backend_fixtures.py,sha256=t5QWwyezHUhxxAlbUuE_eFmpyRaGbnWNNcGPwrO17JM,1571
|
|
35
35
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
36
36
|
tests/conftest.py,sha256=5MLYQOtQoXWl0TRkYntYKNdqpd4hl9m0XTRi5OXanYI,104
|
|
37
|
-
tests/test_config.py,sha256=
|
|
37
|
+
tests/test_config.py,sha256=BGIXTX0XRF634_NMG-ya8v0zruw4PZCZtFGhYVK4DCM,5867
|
|
38
38
|
tests/test_core.py,sha256=JbzB05LWmaaP77uXeTOQtCJD2AJT0zO9zhDfcZ3GNH8,5139
|
|
39
39
|
tests/test_end_to_end.py,sha256=0W5pUES5hek-pXq4NZtpPZqKTORkGCRsDv5_D3rDMjY,3372
|
|
40
40
|
tests/test_error_handling.py,sha256=qPSMKF1qsAHyUME0-krxbIrk38iGKkhAyAah-KwN4NE,1300
|
|
@@ -43,8 +43,8 @@ tests/test_printing.py,sha256=Jz1AjqmqBRjp1JLm6H1oVJyvGaMPlahVXdKnd7UDQFc,2231
|
|
|
43
43
|
tests/test_query.py,sha256=fExmCKXLA7-9j2S2sF_sbvRX_2s6Cp3a7OTcqE25q9g,3864
|
|
44
44
|
tests/test_utils.py,sha256=eUBYrn3xrcgcaxm1X4fqZaX4tRvkbI6rh6BUbNbu9T0,4784
|
|
45
45
|
tests/test_wrappers.py,sha256=TbcTyO2L7fslbzgfDdcVZkencxNQ8cGPZm_iB6c9d6Q,2673
|
|
46
|
-
kleinkram-0.40.0.
|
|
47
|
-
kleinkram-0.40.0.
|
|
48
|
-
kleinkram-0.40.0.
|
|
49
|
-
kleinkram-0.40.0.
|
|
50
|
-
kleinkram-0.40.0.
|
|
46
|
+
kleinkram-0.40.0.dev20250228081255.dist-info/METADATA,sha256=y2qW3auu9kx4VTRvV20CKWZCisrZtWt9KYySkuGXpv0,2760
|
|
47
|
+
kleinkram-0.40.0.dev20250228081255.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
|
48
|
+
kleinkram-0.40.0.dev20250228081255.dist-info/entry_points.txt,sha256=SaB2l5aqhSr8gmaMw2kvQU90a8Bnl7PedU8cWYxkfYo,46
|
|
49
|
+
kleinkram-0.40.0.dev20250228081255.dist-info/top_level.txt,sha256=N3-sJagEHu1Tk1X6Dx1X1q0pLDNbDZpLzRxVftvepds,24
|
|
50
|
+
kleinkram-0.40.0.dev20250228081255.dist-info/RECORD,,
|
tests/test_config.py
CHANGED
|
@@ -7,6 +7,7 @@ from unittest import mock
|
|
|
7
7
|
|
|
8
8
|
import pytest
|
|
9
9
|
|
|
10
|
+
import kleinkram.config
|
|
10
11
|
from kleinkram.config import ACTION_API
|
|
11
12
|
from kleinkram.config import ACTION_API_KEY
|
|
12
13
|
from kleinkram.config import ACTION_S3
|
|
@@ -102,9 +103,26 @@ def test_save_and_load_config(config_path):
|
|
|
102
103
|
config = Config(version="foo")
|
|
103
104
|
|
|
104
105
|
assert not config_path.exists()
|
|
105
|
-
|
|
106
|
+
with mock.patch.object(kleinkram.config.logger, "warning") as mock_warning:
|
|
107
|
+
save_config(config, path=config_path)
|
|
108
|
+
mock_warning.assert_not_called()
|
|
109
|
+
|
|
106
110
|
assert config_path.exists()
|
|
111
|
+
loaded_config = _load_config(path=config_path)
|
|
112
|
+
assert loaded_config == config
|
|
113
|
+
|
|
107
114
|
|
|
115
|
+
def test_save_and_load_config_when_tmpfile_fails(config_path):
|
|
116
|
+
config = Config(version="foo")
|
|
117
|
+
|
|
118
|
+
assert not config_path.exists()
|
|
119
|
+
with mock.patch("tempfile.mkstemp", side_effect=Exception), mock.patch.object(
|
|
120
|
+
kleinkram.config.logger, "warning"
|
|
121
|
+
) as mock_warning:
|
|
122
|
+
save_config(config, path=config_path)
|
|
123
|
+
mock_warning.assert_called_once()
|
|
124
|
+
|
|
125
|
+
assert config_path.exists()
|
|
108
126
|
loaded_config = _load_config(path=config_path)
|
|
109
127
|
assert loaded_config == config
|
|
110
128
|
|
|
File without changes
|
|
File without changes
|