kscale 0.1.0__tar.gz → 0.1.2__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {kscale-0.1.0/kscale.egg-info → kscale-0.1.2}/PKG-INFO +2 -2
- {kscale-0.1.0 → kscale-0.1.2}/kscale/__init__.py +1 -1
- {kscale-0.1.0 → kscale-0.1.2}/kscale/conf.py +1 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/clients/robot_class.py +27 -4
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/utils.py +6 -0
- {kscale-0.1.0 → kscale-0.1.2/kscale.egg-info}/PKG-INFO +2 -2
- {kscale-0.1.0 → kscale-0.1.2}/LICENSE +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/MANIFEST.in +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/README.md +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/api.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/artifacts/__init__.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/artifacts/plane.obj +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/artifacts/plane.urdf +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/cli.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/py.typed +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/requirements-dev.txt +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/requirements.txt +1 -1
- {kscale-0.1.0 → kscale-0.1.2}/kscale/utils/__init__.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/utils/api_base.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/utils/checksum.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/utils/cli.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/__init__.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/api.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/cli/__init__.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/cli/robot.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/cli/robot_class.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/cli/token.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/cli/user.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/clients/__init__.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/clients/base.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/clients/client.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/clients/robot.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/clients/user.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/gen/__init__.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale/web/gen/api.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale.egg-info/SOURCES.txt +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale.egg-info/dependency_links.txt +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale.egg-info/entry_points.txt +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale.egg-info/not-zip-safe +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/kscale.egg-info/requires.txt +1 -1
- {kscale-0.1.0 → kscale-0.1.2}/kscale.egg-info/top_level.txt +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/pyproject.toml +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/setup.cfg +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/setup.py +0 -0
- {kscale-0.1.0 → kscale-0.1.2}/tests/test_dummy.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: kscale
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.2
|
4
4
|
Summary: The kscale project
|
5
5
|
Home-page: https://github.com/kscalelabs/kscale
|
6
6
|
Author: Benjamin Bolte
|
@@ -9,7 +9,6 @@ Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
10
10
|
Requires-Dist: omegaconf
|
11
11
|
Requires-Dist: email_validator
|
12
|
-
Requires-Dist: colorlogging
|
13
12
|
Requires-Dist: aiohttp
|
14
13
|
Requires-Dist: cryptography
|
15
14
|
Requires-Dist: httpx
|
@@ -19,6 +18,7 @@ Requires-Dist: requests
|
|
19
18
|
Requires-Dist: yarl
|
20
19
|
Requires-Dist: aiofiles
|
21
20
|
Requires-Dist: click
|
21
|
+
Requires-Dist: colorlogging
|
22
22
|
Requires-Dist: tabulate
|
23
23
|
Requires-Dist: async-lru
|
24
24
|
Requires-Dist: krec
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"""Defines the client for interacting with the K-Scale robot class endpoints."""
|
2
2
|
|
3
3
|
import hashlib
|
4
|
+
import json
|
4
5
|
import logging
|
5
6
|
from pathlib import Path
|
6
7
|
|
@@ -8,10 +9,13 @@ import httpx
|
|
8
9
|
|
9
10
|
from kscale.web.clients.base import BaseClient
|
10
11
|
from kscale.web.gen.api import RobotClass, RobotDownloadURDFResponse, RobotUploadURDFResponse
|
11
|
-
from kscale.web.utils import get_cache_dir
|
12
|
+
from kscale.web.utils import get_cache_dir, should_refresh_file
|
12
13
|
|
13
14
|
logger = logging.getLogger(__name__)
|
14
15
|
|
16
|
+
UPLOAD_TIMEOUT = 300.0
|
17
|
+
DOWNLOAD_TIMEOUT = 60.0
|
18
|
+
|
15
19
|
|
16
20
|
class RobotClassClient(BaseClient):
|
17
21
|
async def get_robot_classes(self) -> list[RobotClass]:
|
@@ -77,7 +81,9 @@ class RobotClassClient(BaseClient):
|
|
77
81
|
auth=True,
|
78
82
|
)
|
79
83
|
response = RobotUploadURDFResponse.model_validate(data)
|
80
|
-
async with httpx.AsyncClient(
|
84
|
+
async with httpx.AsyncClient(
|
85
|
+
timeout=httpx.Timeout(UPLOAD_TIMEOUT),
|
86
|
+
) as client:
|
81
87
|
async with client.stream(
|
82
88
|
"PUT",
|
83
89
|
response.url,
|
@@ -89,15 +95,26 @@ class RobotClassClient(BaseClient):
|
|
89
95
|
|
90
96
|
async def download_robot_class_urdf(self, class_name: str, *, cache: bool = True) -> Path:
|
91
97
|
cache_path = get_cache_dir() / class_name / "robot.tgz"
|
92
|
-
if cache and cache_path.exists():
|
98
|
+
if cache and cache_path.exists() and not should_refresh_file(cache_path):
|
93
99
|
return cache_path
|
94
100
|
data = await self._request("GET", f"/robots/urdf/{class_name}", auth=True)
|
95
101
|
response = RobotDownloadURDFResponse.model_validate(data)
|
96
102
|
expected_hash = response.md5_hash
|
97
103
|
cache_path.parent.mkdir(parents=True, exist_ok=True)
|
98
104
|
|
105
|
+
# Checks the md5 hash of the file.
|
106
|
+
cache_path_info = cache_path.parent / "info.json"
|
107
|
+
if cache_path_info.exists():
|
108
|
+
with open(cache_path_info, "r") as f:
|
109
|
+
info = json.load(f)
|
110
|
+
if info["md5_hash"] == expected_hash:
|
111
|
+
cache_path.touch()
|
112
|
+
return cache_path
|
113
|
+
|
99
114
|
logger.info("Downloading URDF file from %s", response.url)
|
100
|
-
async with httpx.AsyncClient(
|
115
|
+
async with httpx.AsyncClient(
|
116
|
+
timeout=httpx.Timeout(DOWNLOAD_TIMEOUT),
|
117
|
+
) as client:
|
101
118
|
with open(cache_path, "wb") as file:
|
102
119
|
hash_value = hashlib.md5()
|
103
120
|
async with client.stream("GET", response.url) as r:
|
@@ -111,4 +128,10 @@ class RobotClassClient(BaseClient):
|
|
111
128
|
if hash_value_hex != expected_hash:
|
112
129
|
raise ValueError(f"MD5 hash mismatch: {hash_value_hex} != {expected_hash}")
|
113
130
|
|
131
|
+
# Updates the info file.
|
132
|
+
logger.info("Updating downloaded file information")
|
133
|
+
info = {"md5_hash": hash_value_hex}
|
134
|
+
with open(cache_path_info, "w") as f:
|
135
|
+
json.dump(info, f)
|
136
|
+
|
114
137
|
return cache_path
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
import functools
|
4
4
|
import logging
|
5
|
+
import time
|
5
6
|
from pathlib import Path
|
6
7
|
|
7
8
|
from kscale.conf import Settings
|
@@ -17,6 +18,11 @@ def get_cache_dir() -> Path:
|
|
17
18
|
return Path(Settings.load().www.cache_dir).expanduser().resolve()
|
18
19
|
|
19
20
|
|
21
|
+
def should_refresh_file(file: Path) -> bool:
|
22
|
+
"""Returns whether the file should be refreshed."""
|
23
|
+
return file.exists() and file.stat().st_mtime < time.time() - Settings.load().www.refresh_interval_minutes * 60
|
24
|
+
|
25
|
+
|
20
26
|
@functools.lru_cache
|
21
27
|
def get_artifact_dir(artifact_id: str) -> Path:
|
22
28
|
"""Returns the directory for a specific artifact."""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: kscale
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.2
|
4
4
|
Summary: The kscale project
|
5
5
|
Home-page: https://github.com/kscalelabs/kscale
|
6
6
|
Author: Benjamin Bolte
|
@@ -9,7 +9,6 @@ Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
10
10
|
Requires-Dist: omegaconf
|
11
11
|
Requires-Dist: email_validator
|
12
|
-
Requires-Dist: colorlogging
|
13
12
|
Requires-Dist: aiohttp
|
14
13
|
Requires-Dist: cryptography
|
15
14
|
Requires-Dist: httpx
|
@@ -19,6 +18,7 @@ Requires-Dist: requests
|
|
19
18
|
Requires-Dist: yarl
|
20
19
|
Requires-Dist: aiofiles
|
21
20
|
Requires-Dist: click
|
21
|
+
Requires-Dist: colorlogging
|
22
22
|
Requires-Dist: tabulate
|
23
23
|
Requires-Dist: async-lru
|
24
24
|
Requires-Dist: krec
|
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
|
File without changes
|
File without changes
|
File without changes
|