sapiopycommons 2024.9.25a334__tar.gz → 2024.9.30a335__tar.gz
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-2024.9.25a334 → sapiopycommons-2024.9.30a335}/PKG-INFO +1 -1
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/pyproject.toml +1 -1
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/files/file_util.py +17 -7
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/.gitignore +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/LICENSE +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/README.md +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/__init__.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/callbacks/__init__.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/callbacks/callback_util.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/chem/IndigoMolecules.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/chem/Molecules.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/chem/__init__.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/customreport/__init__.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/customreport/column_builder.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/customreport/custom_report_builder.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/customreport/term_builder.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/datatype/__init__.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/datatype/attachment_util.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/eln/__init__.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/eln/experiment_handler.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/eln/experiment_report_util.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/eln/plate_designer.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/files/__init__.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/files/complex_data_loader.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/files/file_bridge.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/files/file_bridge_handler.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/files/file_data_handler.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/files/file_validator.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/files/file_writer.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/general/__init__.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/general/accession_service.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/general/aliases.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/general/audit_log.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/general/custom_report_util.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/general/exceptions.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/general/popup_util.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/general/sapio_links.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/general/storage_util.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/general/time_util.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/multimodal/multimodal.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/multimodal/multimodal_data.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/processtracking/__init__.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/processtracking/endpoints.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/recordmodel/__init__.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/recordmodel/record_handler.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/rules/__init__.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/rules/eln_rule_handler.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/rules/on_save_rule_handler.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/webhook/__init__.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/webhook/webhook_handlers.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/webhook/webservice_handlers.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/tests/_do_not_add_init_py_here +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/tests/accession_test.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/tests/bio_reg_test.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/tests/chem_test.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/tests/data_type_models.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/tests/kappa.chains.fasta +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/tests/mafft_test.py +0 -0
- {sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/tests/test.gb +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: sapiopycommons
|
|
3
|
-
Version: 2024.9.
|
|
3
|
+
Version: 2024.9.30a335
|
|
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>
|
{sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/files/file_util.py
RENAMED
|
@@ -23,8 +23,8 @@ class FileUtil:
|
|
|
23
23
|
"""
|
|
24
24
|
@staticmethod
|
|
25
25
|
def tokenize_csv(file_bytes: bytes, required_headers: list[str] | None = None, header_row_index: int | None = 0,
|
|
26
|
-
seperator: str = ",", *, encoding: str | None = None,
|
|
27
|
-
|
|
26
|
+
seperator: str = ",", *, encoding: str | None = None, encoding_error: str | None = "strict",
|
|
27
|
+
exception_on_empty: bool = True) -> tuple[list[dict[str, str]], list[list[str]]]:
|
|
28
28
|
"""
|
|
29
29
|
Tokenize a CSV file. The provided file must be uniform. That is, if row 1 has 10 cells, all the rows in the file
|
|
30
30
|
must have 10 cells. Otherwise, the Pandas parser throws a tokenizer exception.
|
|
@@ -39,7 +39,11 @@ class FileUtil:
|
|
|
39
39
|
:param seperator: The character that separates cells in the table.
|
|
40
40
|
:param encoding: The encoding used to read the given file bytes. If not provided, uses utf-8. If your file
|
|
41
41
|
contains a non-utf-8 character, then a UnicodeDecodeError will be thrown. If this happens, consider using
|
|
42
|
-
ISO-8859-1 as the encoding.
|
|
42
|
+
ISO-8859-1 as the encoding, or investigate what encoding would handle the characters in your file.
|
|
43
|
+
:param encoding_error: The error handling behavior if an encoding error is encountered. By default, the behavior
|
|
44
|
+
is "strict", meaning that encoding errors raise an exception. Change this to "ignore" to skip over invalid
|
|
45
|
+
characters or "replace" to replace invalid characters with a ? character. For a full list of options, see
|
|
46
|
+
https://docs.python.org/3/library/codecs.html#error-handlers
|
|
43
47
|
:param exception_on_empty: Throw a user error exception if the provided file bytes result in an empty list in
|
|
44
48
|
the first element of the returned tuple.
|
|
45
49
|
:return: The CSV parsed into a list of dicts where each dict is a row, mapping the headers to the cells for
|
|
@@ -49,7 +53,7 @@ class FileUtil:
|
|
|
49
53
|
# Parse the file bytes into two DataFrames. The first is metadata of the file located above the header row,
|
|
50
54
|
# while the second is the body of the file below the header row.
|
|
51
55
|
file_body, file_metadata = FileUtil.csv_to_data_frames(file_bytes, header_row_index, seperator,
|
|
52
|
-
encoding=encoding)
|
|
56
|
+
encoding=encoding, encoding_error=encoding_error)
|
|
53
57
|
# Parse the metadata from above the header row index into a list of lists.
|
|
54
58
|
metadata: list[list[str]] = FileUtil.data_frame_to_lists(file_metadata)
|
|
55
59
|
# Parse the data from the file body into a list of dicts.
|
|
@@ -90,7 +94,8 @@ class FileUtil:
|
|
|
90
94
|
|
|
91
95
|
@staticmethod
|
|
92
96
|
def csv_to_data_frames(file_bytes: bytes, header_row_index: int | None = 0, seperator: str = ",",
|
|
93
|
-
*, encoding: str | None = None
|
|
97
|
+
*, encoding: str | None = None, encoding_error: str | None = "strict") \
|
|
98
|
+
-> tuple[DataFrame, DataFrame | None]:
|
|
94
99
|
"""
|
|
95
100
|
Parse the file bytes for a CSV into DataFrames. The provided file must be uniform. That is, if row 1 has 10
|
|
96
101
|
cells, all the rows in the file must have 10 cells. Otherwise, the Pandas parser throws a tokenizer exception.
|
|
@@ -103,7 +108,11 @@ class FileUtil:
|
|
|
103
108
|
:param seperator: The character that separates cells in the table.
|
|
104
109
|
:param encoding: The encoding used to read the given file bytes. If not provided, uses utf-8. If your file
|
|
105
110
|
contains a non-utf-8 character, then a UnicodeDecodeError will be thrown. If this happens, consider using
|
|
106
|
-
ISO-8859-1 as the encoding.
|
|
111
|
+
ISO-8859-1 as the encoding, or investigate what encoding would handle the characters in your file.
|
|
112
|
+
:param encoding_error: The error handling behavior if an encoding error is encountered. By default, the behavior
|
|
113
|
+
is "strict", meaning that encoding errors raise an exception. Change this to "ignore" to skip over invalid
|
|
114
|
+
characters or "replace" to replace invalid characters with a ? character. For a full list of options, see
|
|
115
|
+
https://docs.python.org/3/library/codecs.html#error-handlers
|
|
107
116
|
:return: A tuple of two DataFrames. The first is the frame for the CSV table body, while the second is for the
|
|
108
117
|
metadata from above the header row, or None if there is no metadata.
|
|
109
118
|
"""
|
|
@@ -115,7 +124,8 @@ class FileUtil:
|
|
|
115
124
|
# can throw off the header row index.
|
|
116
125
|
file_metadata = pandas.read_csv(file_io, header=None, dtype=dtype(str),
|
|
117
126
|
skiprows=lambda x: x >= header_row_index,
|
|
118
|
-
skip_blank_lines=False, sep=seperator, encoding=encoding
|
|
127
|
+
skip_blank_lines=False, sep=seperator, encoding=encoding,
|
|
128
|
+
encoding_errors=encoding_error)
|
|
119
129
|
with io.BytesIO(file_bytes) as file_io:
|
|
120
130
|
# The use of the dtype argument is to ensure that everything from the file gets read as a string. Added
|
|
121
131
|
# because some numerical values would get ".0" appended to them, even when casting the DataFrame cell to a
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/chem/Molecules.py
RENAMED
|
File without changes
|
{sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/chem/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/eln/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/files/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/general/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/general/aliases.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/rules/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/src/sapiopycommons/webhook/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sapiopycommons-2024.9.25a334 → sapiopycommons-2024.9.30a335}/tests/_do_not_add_init_py_here
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|