From 755cf3a1f005b818ac3e4fc9d901936d488d18ec Mon Sep 17 00:00:00 2001 From: imsenthur Date: Wed, 13 Nov 2024 10:52:14 -0500 Subject: [PATCH] Added url to assemblies df. --- onshape_api/data/preprocess.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/onshape_api/data/preprocess.py b/onshape_api/data/preprocess.py index 7b83986..776e16f 100644 --- a/onshape_api/data/preprocess.py +++ b/onshape_api/data/preprocess.py @@ -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") @@ -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.")