kscale 0.0.8__py3-none-any.whl → 0.0.10__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
kscale/__init__.py CHANGED
@@ -1,5 +1,9 @@
1
1
  """Defines the common interface for the K-Scale Python API."""
2
2
 
3
- __version__ = "0.0.8"
3
+ __version__ = "0.0.10"
4
+
5
+ from pathlib import Path
4
6
 
5
7
  from kscale.api import KScale
8
+
9
+ ROOT_DIR = Path(__file__).parent
@@ -0,0 +1,8 @@
1
+ """Defines some helper functions for working with artifacts."""
2
+
3
+ from pathlib import Path
4
+
5
+ ARTIFACTS_DIR = Path(__file__).parent.resolve()
6
+
7
+ PLANE_OBJ_PATH = ARTIFACTS_DIR / "plane.obj"
8
+ PLANE_URDF_PATH = ARTIFACTS_DIR / "plane.urdf"
kscale/store/api.py CHANGED
@@ -1,6 +1,7 @@
1
1
  """Defines a common interface for the K-Scale Store API."""
2
2
 
3
3
  from pathlib import Path
4
+ from typing import overload
4
5
 
5
6
  from kscale.store.gen.api import UploadArtifactResponse
6
7
  from kscale.store.urdf import download_urdf, upload_urdf
@@ -17,8 +18,47 @@ class StoreAPI(APIBase):
17
18
 
18
19
  self.api_key = api_key
19
20
 
20
- async def urdf(self, artifact_id: str) -> Path:
21
+ async def artifact_root(self, artifact_id: str) -> Path:
21
22
  return await download_urdf(artifact_id)
22
23
 
24
+ @overload
25
+ async def urdf_path(self, artifact_id: str) -> Path: ...
26
+
27
+ @overload
28
+ async def urdf_path(self, artifact_id: str, *, throw_if_missing: bool = True) -> Path | None: ...
29
+
30
+ async def urdf_path(self, artifact_id: str, *, throw_if_missing: bool = True) -> Path | None:
31
+ root_dir = await self.artifact_root(artifact_id)
32
+ urdf_path = next(root_dir.glob("*.urdf"), None)
33
+ if urdf_path is None and throw_if_missing:
34
+ raise FileNotFoundError(f"No URDF found for artifact {artifact_id}")
35
+ return urdf_path
36
+
37
+ @overload
38
+ async def mjcf_path(self, artifact_id: str) -> Path: ...
39
+
40
+ @overload
41
+ async def mjcf_path(self, artifact_id: str, *, throw_if_missing: bool = True) -> Path | None: ...
42
+
43
+ async def mjcf_path(self, artifact_id: str, *, throw_if_missing: bool = True) -> Path | None:
44
+ root_dir = await self.artifact_root(artifact_id)
45
+ mjcf_path = next(root_dir.glob("*.mjcf"), None)
46
+ if mjcf_path is None and throw_if_missing:
47
+ raise FileNotFoundError(f"No MJCF found for artifact {artifact_id}")
48
+ return mjcf_path
49
+
50
+ @overload
51
+ async def xml_path(self, artifact_id: str) -> Path: ...
52
+
53
+ @overload
54
+ async def xml_path(self, artifact_id: str, *, throw_if_missing: bool = True) -> Path | None: ...
55
+
56
+ async def xml_path(self, artifact_id: str, *, throw_if_missing: bool = True) -> Path | None:
57
+ root_dir = await self.artifact_root(artifact_id)
58
+ xml_path = next(root_dir.glob("*.xml"), None)
59
+ if xml_path is None and throw_if_missing:
60
+ raise FileNotFoundError(f"No XML found for artifact {artifact_id}")
61
+ return xml_path
62
+
23
63
  async def upload_urdf(self, listing_id: str, root_dir: Path) -> UploadArtifactResponse:
24
64
  return await upload_urdf(listing_id, root_dir)
kscale/store/pybullet.py CHANGED
@@ -6,9 +6,9 @@ import itertools
6
6
  import logging
7
7
  import math
8
8
  import time
9
- from pathlib import Path
10
9
  from typing import Sequence
11
10
 
11
+ from kscale.artifacts import PLANE_URDF_PATH
12
12
  from kscale.store.urdf import download_urdf
13
13
 
14
14
  logger = logging.getLogger(__name__)
@@ -53,7 +53,7 @@ async def main(args: Sequence[str] | None = None) -> None:
53
53
  p.configureDebugVisualizer(p.COV_ENABLE_MOUSE_PICKING, 1)
54
54
 
55
55
  # Loads the floor plane.
56
- floor = p.loadURDF(str((Path(__file__).parent / "bullet" / "plane.urdf").resolve()))
56
+ floor = p.loadURDF(str(PLANE_URDF_PATH))
57
57
 
58
58
  # Load the robot URDF.
59
59
  start_position = [0.0, 0.0, 1.0]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kscale
3
- Version: 0.0.8
3
+ Version: 0.0.10
4
4
  Summary: The kscale project
5
5
  Home-page: https://github.com/kscalelabs/kscale
6
6
  Author: Benjamin Bolte
@@ -1,25 +1,26 @@
1
- kscale/__init__.py,sha256=1MpcdojomS4ZvErzg6npkz6JgWeelA-mh3PHtjA2ERw,117
1
+ kscale/__init__.py,sha256=s_FPBlHyXyKecFXm57Q2kH3d0O8suiaE8FrI6n0ckXU,178
2
2
  kscale/api.py,sha256=xBtKj8rgZ400r1Xx9LRY0AzSgIIttoXdejmhHhdVGS0,333
3
3
  kscale/conf.py,sha256=9fShFaYTbnrm_eiGjmy8ZtC4Q4m6PQkWPyoF3eNyov8,1424
4
4
  kscale/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  kscale/requirements-dev.txt,sha256=WI7-ea4IRJakmqVMN8QKhOsDGrghwtvk03aIsFaNSIw,130
6
6
  kscale/requirements.txt,sha256=gxo_niYIHsmyxKxvIOegv45s_lvdnIzI2iFJ2TZzx_U,103
7
+ kscale/artifacts/__init__.py,sha256=RK8wdybtCJPgdLLJ8R8-YMi1Ph5ojqAKVJZowHONtgo,232
7
8
  kscale/artifacts/plane.obj,sha256=x59-IIrWpLjhotChiqT2Ul6U8s0RcHkaEeUZb4KXL1c,348
8
9
  kscale/artifacts/plane.urdf,sha256=LCiTk14AyTHjkZ1jvsb0hNaEaJUxDb8Z1JjsgpXu3YM,819
9
10
  kscale/store/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- kscale/store/api.py,sha256=rydanYGg8zlc_cNuWo9YBG_WVtPKMxFgp6fpec-B8M0,671
11
+ kscale/store/api.py,sha256=JBp4h6yz_ESSdB-2FpkD_1-hdI8_iEKh9svzkyy3jhs,2386
11
12
  kscale/store/cli.py,sha256=8ygg_1tZzOOHJotEIgSN9pfumcriPmA31sI_FCFQiTo,859
12
13
  kscale/store/client.py,sha256=R1IDnf2J4ojAcP8nmUUHfXhcHUt4zP0-mxtVI7MIC5U,2664
13
- kscale/store/pybullet.py,sha256=WzA1FVAc19JMY9nUar0go9kcy9BvU8W1lnT9eT1W1LI,7638
14
+ kscale/store/pybullet.py,sha256=zoeATQStuRWgmPhku65xjfgvE3Y8ReheUIAkZnDr2C0,7614
14
15
  kscale/store/urdf.py,sha256=5x8tK2BYv901S_yYWYPWEnHv-3T0ALBQMdDwb70EZFw,6395
15
16
  kscale/store/utils.py,sha256=rFXGkem2oAttAf3bhWmFEhxrqYnaVvlVJsC268IMw6Y,906
16
17
  kscale/store/gen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
18
  kscale/store/gen/api.py,sha256=82D41J6pg9KWdgD0lx7NggLcNS32SpnN8DqE3Md6ON0,9559
18
19
  kscale/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
20
  kscale/utils/api_base.py,sha256=Kk_WtRDdJHmOg6NtHmVxVrcfARSUkhfr29ypLch_pO0,112
20
- kscale-0.0.8.dist-info/LICENSE,sha256=HCN2bImAzUOXldAZZI7JZ9PYq6OwMlDAP_PpX1HnuN0,1071
21
- kscale-0.0.8.dist-info/METADATA,sha256=yCEhXQcLAaMpUqZnVWeK9Rcdv3LGV4u_vYNrUZ9VCbM,2504
22
- kscale-0.0.8.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
23
- kscale-0.0.8.dist-info/entry_points.txt,sha256=PaVs1ivqB0BBdGUsiFkxGUYjGLz05VqagxwRVwi4yV4,54
24
- kscale-0.0.8.dist-info/top_level.txt,sha256=C2ynjYwopg6YjgttnI2dJjasyq3EKNmYp-IfQg9Xms4,7
25
- kscale-0.0.8.dist-info/RECORD,,
21
+ kscale-0.0.10.dist-info/LICENSE,sha256=HCN2bImAzUOXldAZZI7JZ9PYq6OwMlDAP_PpX1HnuN0,1071
22
+ kscale-0.0.10.dist-info/METADATA,sha256=4K7YAFdI1P5PIAAw78lvbyUw1zIAZ_-ZiZr2NFx-o2Q,2505
23
+ kscale-0.0.10.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
24
+ kscale-0.0.10.dist-info/entry_points.txt,sha256=PaVs1ivqB0BBdGUsiFkxGUYjGLz05VqagxwRVwi4yV4,54
25
+ kscale-0.0.10.dist-info/top_level.txt,sha256=C2ynjYwopg6YjgttnI2dJjasyq3EKNmYp-IfQg9Xms4,7
26
+ kscale-0.0.10.dist-info/RECORD,,