From e49a11c0c480017d63f38f0290a4654391932bd9 Mon Sep 17 00:00:00 2001 From: Benjamin Bolte Date: Wed, 21 Aug 2024 19:12:48 -0700 Subject: [PATCH] format --- kscale/formats/mjcf.py | 4 ++++ kscale/store/gen/api.py | 4 +++- kscale/store/mjcf.py | 4 ++-- kscale/utils.py | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/kscale/formats/mjcf.py b/kscale/formats/mjcf.py index a163e44..e847da9 100644 --- a/kscale/formats/mjcf.py +++ b/kscale/formats/mjcf.py @@ -92,6 +92,7 @@ def to_xml(self, root: ET.Element | None = None) -> ET.Element: joint.set("frictionloss", str(self.frictionloss)) return joint + @dataclass class Inertial: mass: float | None = None @@ -108,6 +109,7 @@ def to_xml(self, root: ET.Element | None = None) -> ET.Element: inertial.set("inertia", " ".join(map(str, self.inertia))) return inertial + @dataclass class Geom: name: str | None = None @@ -160,6 +162,7 @@ def to_xml(self, root: ET.Element | None = None) -> ET.Element: geom.set("density", str(self.density)) return geom + @dataclass class Body: name: str @@ -184,6 +187,7 @@ def to_xml(self, root: ET.Element | None = None) -> ET.Element: self.inertial.to_xml(body) # Add inertial to the XML return body + @dataclass class Flag: frictionloss: str | None = None diff --git a/kscale/store/gen/api.py b/kscale/store/gen/api.py index 514ae39..c013321 100644 --- a/kscale/store/gen/api.py +++ b/kscale/store/gen/api.py @@ -266,10 +266,12 @@ class GetBatchListingsResponse(BaseModel): class HTTPValidationError(BaseModel): detail: Optional[List[ValidationError]] = Field(None, title="Detail") + class MjcfInfo(BaseModel): artifact_id: str = Field(..., title="Artifact Id") url: str = Field(..., title="Url") + class MjcfResponse(BaseModel): mjcf: Optional[MjcfInfo] - listing_id: str = Field(..., title="Listing Id") \ No newline at end of file + listing_id: str = Field(..., title="Listing Id") diff --git a/kscale/store/mjcf.py b/kscale/store/mjcf.py index e23e348..44862bf 100644 --- a/kscale/store/mjcf.py +++ b/kscale/store/mjcf.py @@ -155,9 +155,9 @@ def get_listing_dir() -> Path: parser.add_argument("folder_path", help="The path to the folder containing the MJCF files") parsed_args = parser.parse_args(remaining_args) folder_path = Path(parsed_args.folder_path).expanduser().resolve() - + urdf_or_mjcf = contains_urdf_or_mjcf(folder_path) - if urdf_or_mjcf == 'mjcf': + if urdf_or_mjcf == "mjcf": output_filename = f"{listing_id}.tgz" tarball_path = create_tarball(folder_path, output_filename, get_listing_dir()) diff --git a/kscale/utils.py b/kscale/utils.py index 622d07d..9c82d6f 100644 --- a/kscale/utils.py +++ b/kscale/utils.py @@ -80,4 +80,4 @@ def mjcf_to_urdf(input_mjcf: Path) -> None: # Save the combined URDF combined_urdf_editor.saveUrdf(combined_urdf_path) - print(f"Combined URDF saved to: {combined_urdf_path}") \ No newline at end of file + print(f"Combined URDF saved to: {combined_urdf_path}")