sapiopycommons 2025.2.14a434__py3-none-any.whl → 2025.2.14a436__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.

@@ -1,4 +1,5 @@
1
1
  import base64
2
+ import io
2
3
  import math
3
4
  import re
4
5
  from typing import Final, Mapping, Any
@@ -27,6 +28,8 @@ from sapiopycommons.callbacks.field_builder import FieldBuilder
27
28
  from sapiopycommons.general.aliases import AliasUtil, SapioRecord
28
29
  from sapiopycommons.general.exceptions import SapioException
29
30
  from sapiopycommons.general.time_util import TimeUtil
31
+ from sapiopycommons.multimodal.multimodal import MultiModalManager
32
+ from sapiopycommons.multimodal.multimodal_data import ImageDataRequestPojo
30
33
 
31
34
  CREDENTIALS_HEADER: Final[str] = "SAPIO_APP_API_KEY"
32
35
  API_URL_HEADER: Final[str] = "SAPIO_APP_API_URL"
@@ -388,6 +391,32 @@ class AiHelper:
388
391
  file_contents: bytes = f.read()
389
392
  return self.create_attachment_entry(tab, entry_name, file_path, file_contents)
390
393
 
394
+ def smiles_to_svg(self, smiles: list[str]) -> list[bytes]:
395
+ """
396
+ Given a list of SMILES strings, return a list of the corresponding images in SVG format.
397
+
398
+ :param smiles: The SMILES strings to retrieve images for.
399
+ :return: The images in SVG format. The indices of the returned list correspond to the indices of the input
400
+ SMILES.
401
+ """
402
+ if not smiles:
403
+ return []
404
+ reg_man = MultiModalManager(self.user)
405
+ image_list: list[str] = reg_man.load_image_data(ImageDataRequestPojo(smiles, False))
406
+ return [x.encode() for x in image_list]
407
+
408
+ def update_record_images(self, records: list[SapioRecord], images: list[bytes]) -> None:
409
+ """
410
+ Update the images of the given records with the given images.
411
+
412
+ :param records: The records to update the images of.
413
+ :param images: The images to update the records with. Records will be match with the image in the matching
414
+ index of this list.
415
+ """
416
+ for record, image in zip(AliasUtil.to_data_records(records), images):
417
+ with io.BytesIO(image) as bytes_io:
418
+ self.dr_man.set_record_image(record, bytes_io)
419
+
391
420
 
392
421
  class ToolOfToolsHelper:
393
422
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sapiopycommons
3
- Version: 2025.2.14a434
3
+ Version: 2025.2.14a436
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>
@@ -1,4 +1,6 @@
1
1
  sapiopycommons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ sapiopycommons/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ sapiopycommons/ai/tool_of_tools.py,sha256=zdQIgZV0ISyE75GhWY-YHy6V9ZM6FM4xXZvEmlJ0lME,33737
2
4
  sapiopycommons/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
5
  sapiopycommons/callbacks/callback_util.py,sha256=68lPK8GtE6zd8C0fQaMLxT57PtU-6HnO37Zk-u56Mrs,129933
4
6
  sapiopycommons/callbacks/field_builder.py,sha256=p2XacN99MuKk3ite8GAqstUMpixqugul2CsC4gB83-o,38620
@@ -14,8 +16,6 @@ sapiopycommons/datatype/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
14
16
  sapiopycommons/datatype/attachment_util.py,sha256=_l2swuP8noIGAl4bwzBUEhr6YlN_OVZl3-gi1XqFHYA,3364
15
17
  sapiopycommons/datatype/data_fields.py,sha256=C6HpqtEuF0KsxhlBUprfyv1XguaXql3EYWVbh8y-IFU,4064
16
18
  sapiopycommons/datatype/pseudo_data_types.py,sha256=6TG7aJxgmUZ8FQkWBcgmbK5oy7AFFNtKOPpi1w1OOYA,27657
17
- sapiopycommons/elain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- sapiopycommons/elain/tool_of_tools.py,sha256=ciVans-wV5yuUjCImgAgqJsiWN3g89OrtGoR2Y6IdLE,32379
19
19
  sapiopycommons/eln/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  sapiopycommons/eln/experiment_handler.py,sha256=8hmR7sawDo9K6iBwB44QSoxlH1M91inor7dfuXQ4LKs,69323
21
21
  sapiopycommons/eln/experiment_report_util.py,sha256=EA2Iq8gW17bSEI6lPoHYQQ-fDvG4O28RWOoTPXpOlUw,36640
@@ -58,7 +58,7 @@ sapiopycommons/webhook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
58
58
  sapiopycommons/webhook/webhook_context.py,sha256=D793uLsb1691SalaPnBUk3rOSxn_hYLhdvkaIxjNXss,1909
59
59
  sapiopycommons/webhook/webhook_handlers.py,sha256=L0HetSm43NvA5KyW3xbLpGFh2DbAaeZJVtXIEl2fvV8,39689
60
60
  sapiopycommons/webhook/webservice_handlers.py,sha256=Y5dHx_UFWFuSqaoPL6Re-fsKYRuxvCWZ8bj6KSZ3jfM,14285
61
- sapiopycommons-2025.2.14a434.dist-info/METADATA,sha256=F8Gim4X_8zcHuP5NJt8PT49HyDnR-s0koyDRGVHav0Q,3143
62
- sapiopycommons-2025.2.14a434.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
63
- sapiopycommons-2025.2.14a434.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
64
- sapiopycommons-2025.2.14a434.dist-info/RECORD,,
61
+ sapiopycommons-2025.2.14a436.dist-info/METADATA,sha256=8bjTtK1h5j5TnmkppQddbsbMOj5Bz9E5wO60JoVfnEs,3143
62
+ sapiopycommons-2025.2.14a436.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
63
+ sapiopycommons-2025.2.14a436.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
64
+ sapiopycommons-2025.2.14a436.dist-info/RECORD,,
File without changes