sapiopycommons 2025.9.10a743__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.
- sapiopycommons/ai/tool_service_base.py +26 -4
- {sapiopycommons-2025.9.10a743.dist-info → sapiopycommons-2025.9.10a745.dist-info}/METADATA +1 -1
- {sapiopycommons-2025.9.10a743.dist-info → sapiopycommons-2025.9.10a745.dist-info}/RECORD +5 -5
- {sapiopycommons-2025.9.10a743.dist-info → sapiopycommons-2025.9.10a745.dist-info}/WHEEL +0 -0
- {sapiopycommons-2025.9.10a743.dist-info → sapiopycommons-2025.9.10a745.dist-info}/licenses/LICENSE +0 -0
|
@@ -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
|
|
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, \
|
|
@@ -663,7 +665,7 @@ class ToolBase(ABC):
|
|
|
663
665
|
string_properties=StringPropertiesPbo(
|
|
664
666
|
default_value=default_value,
|
|
665
667
|
max_length=max_length,
|
|
666
|
-
field_validator=FieldValidatorPbo(validation_regex, error_msg) if validation_regex else None
|
|
668
|
+
field_validator=FieldValidatorPbo(validation_regex=validation_regex, error_message=error_msg) if validation_regex else None
|
|
667
669
|
)
|
|
668
670
|
))
|
|
669
671
|
|
|
@@ -697,7 +699,7 @@ class ToolBase(ABC):
|
|
|
697
699
|
default_value=default_value,
|
|
698
700
|
static_list_values=allowed_values,
|
|
699
701
|
direct_edit=direct_edit,
|
|
700
|
-
field_validator=FieldValidatorPbo(validation_regex, error_msg) if validation_regex else None
|
|
702
|
+
field_validator=FieldValidatorPbo(validation_regex=validation_regex, error_message=error_msg) if validation_regex else None
|
|
701
703
|
)
|
|
702
704
|
))
|
|
703
705
|
|
|
@@ -732,7 +734,7 @@ class ToolBase(ABC):
|
|
|
732
734
|
static_list_values=allowed_values,
|
|
733
735
|
multi_select=True,
|
|
734
736
|
direct_edit=direct_edit,
|
|
735
|
-
field_validator=FieldValidatorPbo(validation_regex, error_msg) if validation_regex else None
|
|
737
|
+
field_validator=FieldValidatorPbo(validation_regex=validation_regex, error_message=error_msg) if validation_regex else None
|
|
736
738
|
)
|
|
737
739
|
))
|
|
738
740
|
|
|
@@ -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.
|
|
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=
|
|
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.
|
|
103
|
-
sapiopycommons-2025.9.
|
|
104
|
-
sapiopycommons-2025.9.
|
|
105
|
-
sapiopycommons-2025.9.
|
|
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,,
|
|
File without changes
|
{sapiopycommons-2025.9.10a743.dist-info → sapiopycommons-2025.9.10a745.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|