Skip to content

Commit

Permalink
Added url to assemblies df.
Browse files Browse the repository at this point in the history
  • Loading branch information
senthurayyappan committed Nov 13, 2024
1 parent b6cca9b commit 755cf3a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion onshape_api/data/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def process_all_checkpoints(client: Client):

# now for every elementId in the list, we will have a separate row
assemblies_df = assemblies_df.explode("elementId")
assembly_df["url"] = assembly_df.apply(get_assembly_url, axis=1)
assemblies_df.to_parquet("assemblies.parquet", engine="pyarrow")


Expand Down Expand Up @@ -163,6 +164,17 @@ def validate_assembly_json(json_file_path: str):
return Assembly.model_validate(assembly_json)


def get_assembly_url(row):
return generate_url(row["documentId"], row["wtype"], row["workspaceId"], row["elementId"])


if __name__ == "__main__":
client = Client()
save_all_jsons(client)
# save_all_jsons(client)

try:
assembly_df = pd.read_parquet("assemblies.parquet", engine="pyarrow")
LOGGER.info(assembly_df.head(), assembly_df.shape)

except FileNotFoundError:
LOGGER.warning("assemblies.parquet not found. Please run get_assembly_df() first.")

0 comments on commit 755cf3a

Please sign in to comment.