sapiopycommons 2025.9.10a744__py3-none-any.whl → 2025.9.10a745__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.

@@ -5,14 +5,16 @@ import io
5
5
  import json
6
6
  import logging
7
7
  import re
8
+ import subprocess
8
9
  import traceback
9
10
  from abc import abstractmethod, ABC
10
11
  from logging import Logger
12
+ from subprocess import CompletedProcess
11
13
  from typing import Any, Iterable, Mapping
12
14
 
13
15
  from grpc import ServicerContext
14
16
  from sapiopylib.rest.User import SapioUser, ensure_logger_initialized
15
- from sapiopylib.rest.pojo.datatype.FieldDefinition import AbstractVeloxFieldDefinition, FieldValidator
17
+ from sapiopylib.rest.pojo.datatype.FieldDefinition import AbstractVeloxFieldDefinition
16
18
 
17
19
  from sapiopycommons.ai.protoapi.fielddefinitions.fields_pb2 import FieldValueMapPbo, FieldValuePbo
18
20
  from sapiopycommons.ai.protoapi.fielddefinitions.velox_field_def_pb2 import VeloxFieldDefPbo, FieldTypePbo, \
@@ -828,6 +830,26 @@ class ToolBase(ABC):
828
830
  """
829
831
  pass
830
832
 
833
+ def call_subprocess(self, args: list[str], cwd: str | None = None, **kwargs) -> CompletedProcess[str]:
834
+ """
835
+ Call a subprocess with the given arguments, logging the command and any errors that occur.
836
+ This function will raise an exception if the return code of the subprocess is non-zero. The output of the
837
+ subprocess will be captured and returned as part of the CompletedProcess object.
838
+
839
+ :param args: The list of arguments to pass to the subprocess.
840
+ :param cwd: The working directory to run the subprocess in. If None, the current working directory is used.
841
+ :param kwargs: Additional keyword arguments to pass to subprocess.run().
842
+ :return: The CompletedProcess object returned by subprocess.run().
843
+ """
844
+ try:
845
+ self.log_info(f"Running subprocess with command: {' '.join(args)}")
846
+ return subprocess.run(args, check=True, capture_output=True, text=True, cwd=cwd, **kwargs)
847
+ except subprocess.CalledProcessError as e:
848
+ self.log_error(f"Error running subprocess. Return code: {e.returncode}")
849
+ self.log_error(f"STDOUT: {e.stdout}")
850
+ self.log_error(f"STDERR: {e.stderr}")
851
+ raise
852
+
831
853
  def log_info(self, message: str) -> None:
832
854
  """
833
855
  Log an info message for this tool. If verbose logging is enabled, this message will be included in the logs
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sapiopycommons
3
- Version: 2025.9.10a744
3
+ Version: 2025.9.10a745
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>
@@ -4,7 +4,7 @@ sapiopycommons/ai/converter_service_base.py,sha256=TMSyEekbbqMk9dRuAtLlSJ1sA1H8K
4
4
  sapiopycommons/ai/protobuf_utils.py,sha256=cBjbxoFAwU02kNUxEce95WnMU2CMuDD-qFaeWgvQJMQ,24599
5
5
  sapiopycommons/ai/server.py,sha256=XDm_mj1yWHw-xQRFsFRHnsGw2JU0wsW2mR22P8PB09A,5744
6
6
  sapiopycommons/ai/test_client.py,sha256=-kMXXU_f5FAB7n4UX66NT8I8G52M0eZjn-hpESN_io8,16330
7
- sapiopycommons/ai/tool_service_base.py,sha256=dEuhaQlHK0QNY0izDMYrh6iGGh-_E3X5WdWyhTmTmCY,49944
7
+ sapiopycommons/ai/tool_service_base.py,sha256=AQO9kXhIKofkpmWRU0fq5TIcAr0kyt9vdllmMsYYkJs,51213
8
8
  sapiopycommons/ai/protoapi/fielddefinitions/fields_pb2.py,sha256=8tKXwLXcqFGdQHHSEBSi6Fd7dcaCFoOqmhjzqhenb_M,2372
9
9
  sapiopycommons/ai/protoapi/fielddefinitions/fields_pb2.pyi,sha256=FwtXmNAf7iYGEFm4kbqb04v77jNHbZg18ZmEDhle_bU,1444
10
10
  sapiopycommons/ai/protoapi/fielddefinitions/fields_pb2_grpc.py,sha256=uO25bcnfGqXpP4ggUur54Nr73Wj-DGWftExzLNcxdHI,931
@@ -99,7 +99,7 @@ sapiopycommons/webhook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
99
99
  sapiopycommons/webhook/webhook_context.py,sha256=D793uLsb1691SalaPnBUk3rOSxn_hYLhdvkaIxjNXss,1909
100
100
  sapiopycommons/webhook/webhook_handlers.py,sha256=7o_wXOruhT9auNh8OfhJAh4WhhiPKij67FMBSpGPICc,39939
101
101
  sapiopycommons/webhook/webservice_handlers.py,sha256=cvW6Mk_110BzYqkbk63Kg7jWrltBCDALOlkJRu8h4VQ,14300
102
- sapiopycommons-2025.9.10a744.dist-info/METADATA,sha256=72aJpnGlZiqo_L-EB1JpdUyOmP8vLTNiLoOC8_RZ4o8,3143
103
- sapiopycommons-2025.9.10a744.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
104
- sapiopycommons-2025.9.10a744.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
105
- sapiopycommons-2025.9.10a744.dist-info/RECORD,,
102
+ sapiopycommons-2025.9.10a745.dist-info/METADATA,sha256=Xn9XSg5cqnIgR5qXWfQsLbWkP1OiXcANtCV4dORGkbQ,3143
103
+ sapiopycommons-2025.9.10a745.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
104
+ sapiopycommons-2025.9.10a745.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
105
+ sapiopycommons-2025.9.10a745.dist-info/RECORD,,