sapiopycommons 2025.10.10a778__py3-none-any.whl → 2025.10.10a779__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sapiopycommons might be problematic. Click here for more details.

@@ -43,6 +43,8 @@ class AgentOutput:
43
43
  status: str
44
44
  message: str
45
45
 
46
+ # Outputs are lists of lists, where the outer lists are the different outputs of the tool, and the inner lists
47
+ # are the entries for that output.
46
48
  binary_output: list[list[bytes]]
47
49
  csv_output: list[list[dict[str, Any]]]
48
50
  json_output: list[list[dict[str, Any]]]
@@ -61,10 +63,51 @@ class AgentOutput:
61
63
  self.new_records = []
62
64
  self.logs = []
63
65
 
66
+ def save_outputs(self, path: str = "test_outputs", file_extensions: list[str] | None = None) -> None:
67
+ """
68
+ Save all outputs to files in the specified directory. The files will be named according to the agent name
69
+ and the output type.
70
+
71
+ :param path: The directory to save the output files to.
72
+ :param file_extensions: A list of file extensions to use for binary output files. The length of this list
73
+ should match the number of binary outputs.
74
+ """
75
+ if not self:
76
+ return
77
+ import os
78
+ os.makedirs(path, exist_ok=True)
79
+ if self.binary_output and (not file_extensions or len(file_extensions) != len(self.binary_output)):
80
+ raise ValueError("File extensions must be provided for each binary output.")
81
+ for i, output in enumerate(self.binary_output):
82
+ ext: str = "." + file_extensions[i].lstrip(".")
83
+ for j, entry in enumerate(output):
84
+ with open(os.path.join(path, self.agent_name, f"binary_output_{i}_{j}{ext}"), "wb") as f:
85
+ f.write(entry)
86
+ for i, output in enumerate(self.csv_output):
87
+ with open(os.path.join(path, self.agent_name, f"csv_output_{i}.csv"), "w", encoding="utf-8") as f:
88
+ headers = output[0].keys()
89
+ f.write(",".join(headers) + "\n")
90
+ for row in output:
91
+ f.write(",".join(f'"{str(row[h])}"' for h in headers) + "\n")
92
+ for i, output in enumerate(self.json_output):
93
+ for j, entry in enumerate(output):
94
+ with open(os.path.join(path, self.agent_name, f"json_output_{i}_{j}.json"), "w", encoding="utf-8") as f:
95
+ json.dump(entry, f, indent=2)
96
+ for i, output in enumerate(self.text_output):
97
+ for j, entry in enumerate(output):
98
+ with open(os.path.join(path, self.agent_name, f"text_output_{i}_{j}.txt"), "w", encoding="utf-8") as f:
99
+ f.write(entry)
100
+
64
101
  def __bool__(self):
102
+ """
103
+ Return True if the agent call was successful, False otherwise.
104
+ """
65
105
  return self.status == "Success"
66
106
 
67
107
  def __str__(self):
108
+ """
109
+ Return a string representing a summary of the agent output.
110
+ """
68
111
  ret_val: str = f"{self.agent_name} Output:\n"
69
112
  ret_val += f"\tStatus: {self.status}\n"
70
113
  ret_val += f"\tMessage: {self.message}\n"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sapiopycommons
3
- Version: 2025.10.10a778
3
+ Version: 2025.10.10a779
4
4
  Summary: Official Sapio Python API Utilities Package
5
5
  Project-URL: Homepage, https://github.com/sapiosciences
6
6
  Author-email: Jonathan Steck <jsteck@sapiosciences.com>, Yechen Qiao <yqiao@sapiosciences.com>
@@ -6,7 +6,7 @@ sapiopycommons/ai/external_credentials.py,sha256=40AI7VtHf6PzvwJLR_mZemUCrfAUvC-
6
6
  sapiopycommons/ai/protobuf_utils.py,sha256=cBjbxoFAwU02kNUxEce95WnMU2CMuDD-qFaeWgvQJMQ,24599
7
7
  sapiopycommons/ai/request_validation.py,sha256=TD2EUi_G5cy1OOVK1AmY2SQc3PEoAKGWs2pT8Qnp2Oo,25092
8
8
  sapiopycommons/ai/server.py,sha256=gutSskn_Fenq1uz0DDMvjx4QVFiKt2WVEP3-01a69eU,6384
9
- sapiopycommons/ai/test_client.py,sha256=C35Z9m4wCQhWPsX_p59VD8eAHP1OkZoJjnUVIdxSmZA,16546
9
+ sapiopycommons/ai/test_client.py,sha256=jHIKaBy2jta2UCcci6z0dvX_BZZuiV_0z2HPr9dEI_s,18897
10
10
  sapiopycommons/ai/protoapi/externalcredentials/external_credentials_pb2.py,sha256=mEonoj6Iq-AyvO4m3YsPYu85aZfD1E0a0cL8B9yPfEo,2481
11
11
  sapiopycommons/ai/protoapi/externalcredentials/external_credentials_pb2.pyi,sha256=sfExq8fFwIwFxCpV50ytdxW5ePNBjJBr_80_trq_JQw,1658
12
12
  sapiopycommons/ai/protoapi/externalcredentials/external_credentials_pb2_grpc.py,sha256=TNS1CB_QGBSa1YU9sYR_hF-pmBwv2GpxjaNQoM_r9iU,948
@@ -106,7 +106,7 @@ sapiopycommons/webhook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
106
106
  sapiopycommons/webhook/webhook_context.py,sha256=D793uLsb1691SalaPnBUk3rOSxn_hYLhdvkaIxjNXss,1909
107
107
  sapiopycommons/webhook/webhook_handlers.py,sha256=7o_wXOruhT9auNh8OfhJAh4WhhiPKij67FMBSpGPICc,39939
108
108
  sapiopycommons/webhook/webservice_handlers.py,sha256=cvW6Mk_110BzYqkbk63Kg7jWrltBCDALOlkJRu8h4VQ,14300
109
- sapiopycommons-2025.10.10a778.dist-info/METADATA,sha256=9wZ4a_ATdKHyPMio03ozGETcptRc1PGztlbDFXd1CVo,3143
110
- sapiopycommons-2025.10.10a778.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
111
- sapiopycommons-2025.10.10a778.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
112
- sapiopycommons-2025.10.10a778.dist-info/RECORD,,
109
+ sapiopycommons-2025.10.10a779.dist-info/METADATA,sha256=5rW00M6gy8crugEHSZZCOCNdoe-Bi8gbVBwfOqoNk0U,3143
110
+ sapiopycommons-2025.10.10a779.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
111
+ sapiopycommons-2025.10.10a779.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
112
+ sapiopycommons-2025.10.10a779.dist-info/RECORD,,