Skip to content

Commit

Permalink
RCS update (python) (#72)
Browse files Browse the repository at this point in the history
Co-authored-by: Ariana Carnielli <22528786+arianacarnielli@users.noreply.github.com>
  • Loading branch information
dbiguenet and arianacarnielli authored Jan 26, 2024
1 parent d24b073 commit 029cb00
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
6 changes: 3 additions & 3 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"

[project]
name = "reality_apis"
version = "1.0.5"
version = "1.0.6"
authors = [
{ name="Bentley Systems" },
]
description = "This package contains a SDK for Reality Modeling, Reality Analysis and Reality Conversion iTwin APIs as well as Reality Data API utils. It provides classes, functions and examples to upload local data to ContextShare, run jobs and download the results."
description = "This package contains a SDK for Reality Modeling, Reality Analysis and Reality Conversion iTwin APIs as well as Reality Management API utils. It provides classes, functions and examples to upload local data to ContextShare, run jobs and download the results."
readme = "README.md"
license = {text = "MIT"}
requires-python = ">=3.8"
Expand All @@ -33,4 +33,4 @@ include = ["reality_apis*", "token_factory","contextscene"]
"Reality Analysis Api reference" = "https://developer.bentley.com/apis/realitydataanalysis/"
"Reality Modeling Api reference" = "https://developer.bentley.com/apis/contextcapture/"
"Reality Conversion Api reference" = "https://developer.bentley.com/apis/realityconversion/"
"Reality Data Api reference" = "https://developer.bentley.com/apis/reality-data/"
"Reality Management Api reference" = "https://developer.bentley.com/apis/reality-management/"
28 changes: 20 additions & 8 deletions python/reality_apis/RC/rcs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ class RCJobSettings:
outputs: Possible outputs for this job. Fill the types of outputs you want for the job with True before passing
the settings to create_job.
engines: Quantity of engines to be used by the job.
merge: If true, all the input files from multiple containers will be merged into one output file. Else output
file will be created per input file.
"""

def __init__(self) -> None:
self.inputs: RCJobSettings.Inputs = self.Inputs()
self.outputs: RCJobSettings.Outputs = self.Outputs()
self.engines: int = 0
self.merge: bool = True

def to_json(self) -> tuple[dict, dict, dict]:
"""
Expand All @@ -44,20 +47,22 @@ def to_json(self) -> tuple[dict, dict, dict]:
inputs_dict = {"inputs": list()}

for rd_id in self.inputs.LAS:
inputs_dict["inputs"].append({"type": "LAS", "id": rd_id})
inputs_dict["inputs"].append({"id": rd_id})
for rd_id in self.inputs.LAZ:
inputs_dict["inputs"].append({"type": "LAZ", "id": rd_id})
inputs_dict["inputs"].append({"id": rd_id})
for rd_id in self.inputs.PLY:
inputs_dict["inputs"].append({"type": "PLY", "id": rd_id})
inputs_dict["inputs"].append({"id": rd_id})
for rd_id in self.inputs.E57:
inputs_dict["inputs"].append({"type": "E57", "id": rd_id})
inputs_dict["inputs"].append({"id": rd_id})

outputs_dict = {"outputs": list()}

if self.outputs.OPC:
outputs_dict["outputs"].append("OPC")
if self.outputs.PNTS:
outputs_dict["outputs"].append("PNTS")

options_dict = {"options": {"processingEngines": self.engines}}
options_dict = {"options": {"processingEngines": self.engines, "merge": str(self.merge)}}

return inputs_dict, outputs_dict, options_dict

Expand Down Expand Up @@ -89,17 +94,22 @@ def from_json(cls, settings_json: dict) -> ReturnValue[RCJobSettings]:
)

outputs_json = settings_json.get("outputs", [])
new_job_settings.outputs.OPC = []

for output_dict in outputs_json:
if output_dict["format"] == "OPC":
if output_dict["type"] == "OPC":
new_job_settings.outputs.OPC = []
new_job_settings.outputs.OPC.append(output_dict["id"])
if output_dict["type"] == "PNTS":
new_job_settings.outputs.PNTS = []
new_job_settings.outputs.PNTS.append(output_dict["id"])
else:
raise TypeError(
"found non expected output format" + output_dict["format"]
"found non expected output type" + output_dict["type"]
)

options_json = settings_json.get("options", {})
new_job_settings.engines = int(options_json.get("processingEngines", 0))
new_job_settings.merge = bool(options_json.get("merge", True))

except (KeyError, TypeError) as e:
return ReturnValue(value=cls(), error=str(e))
Expand Down Expand Up @@ -128,10 +138,12 @@ class Outputs:
Attributes:
OPC: Either a boolean to indicate conversion type or a list of created OPC files ids.
PNTS: Either a boolean to indicate conversion type or a list of created PNTS files ids.
"""

def __init__(self) -> None:
self.OPC: Union[bool, List[str]] = False
self.PNTS: Union[bool, List[str]] = False


class RCJobCostParameters:
Expand Down
1 change: 1 addition & 0 deletions python/reality_apis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class RealityDataType(Enum):
ThreeMX = "3MX"
ThreeSM = "3SM"
Cesium = "Cesium3DTiles"
E57 = "E57"
Unstructured = "Unstructured"


Expand Down

0 comments on commit 029cb00

Please sign in to comment.