sapiopycommons 2024.11.25a373__tar.gz → 2024.12.4a375__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.

Files changed (77) hide show
  1. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/PKG-INFO +1 -1
  2. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/pyproject.toml +1 -1
  3. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/eln/experiment_handler.py +1 -1
  4. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/general/time_util.py +83 -5
  5. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/.gitignore +0 -0
  6. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/LICENSE +0 -0
  7. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/README.md +0 -0
  8. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/__init__.py +0 -0
  9. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/callbacks/__init__.py +0 -0
  10. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/callbacks/callback_util.py +0 -0
  11. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/callbacks/field_builder.py +0 -0
  12. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/chem/IndigoMolecules.py +0 -0
  13. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/chem/Molecules.py +0 -0
  14. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/chem/__init__.py +0 -0
  15. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/customreport/__init__.py +0 -0
  16. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/customreport/column_builder.py +0 -0
  17. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/customreport/custom_report_builder.py +0 -0
  18. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/customreport/term_builder.py +0 -0
  19. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/datatype/__init__.py +0 -0
  20. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/datatype/attachment_util.py +0 -0
  21. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/datatype/data_fields.py +0 -0
  22. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/datatype/pseudo_data_types.py +0 -0
  23. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/eln/__init__.py +0 -0
  24. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/eln/experiment_report_util.py +0 -0
  25. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/eln/plate_designer.py +0 -0
  26. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/files/__init__.py +0 -0
  27. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/files/complex_data_loader.py +0 -0
  28. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/files/file_bridge.py +0 -0
  29. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/files/file_bridge_handler.py +0 -0
  30. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/files/file_data_handler.py +0 -0
  31. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/files/file_util.py +0 -0
  32. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/files/file_validator.py +0 -0
  33. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/files/file_writer.py +0 -0
  34. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/flowcyto/flow_cyto.py +0 -0
  35. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/flowcyto/flowcyto_data.py +0 -0
  36. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/general/__init__.py +0 -0
  37. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/general/accession_service.py +0 -0
  38. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/general/aliases.py +0 -0
  39. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/general/audit_log.py +0 -0
  40. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/general/custom_report_util.py +0 -0
  41. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/general/exceptions.py +0 -0
  42. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/general/popup_util.py +0 -0
  43. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/general/sapio_links.py +0 -0
  44. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/general/storage_util.py +0 -0
  45. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/multimodal/multimodal.py +0 -0
  46. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/multimodal/multimodal_data.py +0 -0
  47. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/processtracking/__init__.py +0 -0
  48. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/processtracking/custom_workflow_handler.py +0 -0
  49. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/processtracking/endpoints.py +0 -0
  50. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/recordmodel/__init__.py +0 -0
  51. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/recordmodel/record_handler.py +0 -0
  52. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/rules/__init__.py +0 -0
  53. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/rules/eln_rule_handler.py +0 -0
  54. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/rules/on_save_rule_handler.py +0 -0
  55. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/sftpconnect/__init__.py +0 -0
  56. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/sftpconnect/sftp_builder.py +0 -0
  57. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/webhook/__init__.py +0 -0
  58. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/webhook/webhook_context.py +0 -0
  59. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/webhook/webhook_handlers.py +0 -0
  60. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/src/sapiopycommons/webhook/webservice_handlers.py +0 -0
  61. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/AF-A0A009IHW8-F1-model_v4.cif +0 -0
  62. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/_do_not_add_init_py_here +0 -0
  63. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/accession_test.py +0 -0
  64. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/bio_reg_test.py +0 -0
  65. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/chem_test.py +0 -0
  66. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/chem_test_curation_queue.py +0 -0
  67. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/curation_queue_test.sdf +0 -0
  68. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/data_type_models.py +0 -0
  69. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/flowcyto/101_DEN084Y5_15_E01_008_clean.fcs +0 -0
  70. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/flowcyto/101_DEN084Y5_15_E03_009_clean.fcs +0 -0
  71. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/flowcyto/101_DEN084Y5_15_E05_010_clean.fcs +0 -0
  72. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/flowcyto/8_color_ICS.wsp +0 -0
  73. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/flowcyto/COVID19_W_001_O.fcs +0 -0
  74. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/flowcyto_test.py +0 -0
  75. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/kappa.chains.fasta +0 -0
  76. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/mafft_test.py +0 -0
  77. {sapiopycommons-2024.11.25a373 → sapiopycommons-2024.12.4a375}/tests/test.gb +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sapiopycommons
3
- Version: 2024.11.25a373
3
+ Version: 2024.12.4a375
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 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "sapiopycommons"
7
- version='2024.11.25a373'
7
+ version='2024.12.04a375'
8
8
  authors = [
9
9
  { name="Jonathan Steck", email="jsteck@sapiosciences.com" },
10
10
  { name="Yechen Qiao", email="yqiao@sapiosciences.com" },
@@ -824,7 +824,7 @@ class ExperimentHandler:
824
824
  The record to remove from the given step.
825
825
  The record may be provided as either a DataRecord, PyRecordModel, or WrappedRecordModel.
826
826
  """
827
- self.remove_eln_row(step, [record])
827
+ self.remove_eln_rows(step, [record])
828
828
 
829
829
  def add_sample_details(self, step: Step, samples: list[RecordModel], wrapper_type: type[WrappedType]) \
830
830
  -> list[PyRecordModel | WrappedType]:
@@ -2,9 +2,12 @@ from __future__ import annotations
2
2
 
3
3
  import time
4
4
  from datetime import datetime
5
+ from typing import Any
5
6
 
6
7
  import pytz
7
8
 
9
+ from sapiopycommons.general.exceptions import SapioException
10
+
8
11
  __timezone = None
9
12
  """The default timezone. Use TimeUtil.set_default_timezone in a global context before making use of TimeUtil."""
10
13
 
@@ -26,7 +29,7 @@ class TimeUtil:
26
29
  with static date fields, use "UTC" as your input timezone.
27
30
  """
28
31
  @staticmethod
29
- def get_default_timezone():
32
+ def get_default_timezone() -> Any:
30
33
  """
31
34
  Returns the timezone that TimeUtil is currently using as its default.
32
35
  """
@@ -45,7 +48,7 @@ class TimeUtil:
45
48
  __timezone = TimeUtil.__to_tz(new_timezone)
46
49
 
47
50
  @staticmethod
48
- def __to_tz(timezone: str | int = None):
51
+ def __to_tz(timezone: str | int = None) -> Any:
49
52
  """
50
53
  :param timezone: Either the name of a timezone, a UTC offset in seconds, or None if the default should be used.
51
54
  :return: The timezone object to use for the given input. If the input is None, uses the default timezone.
@@ -55,11 +58,28 @@ class TimeUtil:
55
58
  # because pytz may return timezones from strings in Local Mean Time instead of a timezone with a UTC offset.
56
59
  # LMT may be a few minutes off of the actual time in that timezone right now.
57
60
  # https://stackoverflow.com/questions/35462876
58
- offset: int = int(datetime.now(pytz.timezone(timezone)).utcoffset().total_seconds() / 60)
59
- return pytz.FixedOffset(offset)
61
+ offset: int = TimeUtil.__get_timezone_offset(timezone)
62
+ # This function takes an offset in minutes, so divide the provided offset seconds by 60.
63
+ return pytz.FixedOffset(offset // 60)
60
64
  if isinstance(timezone, int):
61
65
  return pytz.FixedOffset(timezone // 60)
62
- return TimeUtil.get_default_timezone()
66
+ if timezone is None:
67
+ return TimeUtil.get_default_timezone()
68
+ raise SapioException(f"Unhandled timezone object of type {type(timezone)}: {timezone}")
69
+
70
+ @staticmethod
71
+ def __get_timezone_offset(timezone: str | int | None) -> int:
72
+ """
73
+ :param timezone: Either the name of a timezone, a UTC offset in seconds, or None if the default should be used.
74
+ :return: The UTC offset in seconds of the provided timezone.
75
+ """
76
+ if isinstance(timezone, int):
77
+ return timezone
78
+ if isinstance(timezone, str):
79
+ timezone = pytz.timezone(timezone)
80
+ if timezone is None:
81
+ timezone = TimeUtil.get_default_timezone()
82
+ return int(datetime.now(timezone).utcoffset().total_seconds())
63
83
 
64
84
  @staticmethod
65
85
  def current_time(timezone: str | int = None) -> datetime:
@@ -127,6 +147,64 @@ class TimeUtil:
127
147
  tz = TimeUtil.__to_tz(timezone)
128
148
  return int(datetime.strptime(time_point, time_format).replace(tzinfo=tz).timestamp() * 1000)
129
149
 
150
+ # FR-47296: Provide functions for shifting between timezones.
151
+ @staticmethod
152
+ def shift_now(to_timezone: str = "UTC", from_timezone: str | None = None) -> int:
153
+ """
154
+ Take the current time in from_timezone and output the epoch timestamp that would display that same time in
155
+ to_timezone. A use case for this is when dealing with static date fields to convert a provided timestamp to the
156
+ value necessary to display that timestamp in the same way when viewed in the static date field.
157
+
158
+ :param to_timezone: The timezone to shift to. If not provided, uses UTC.
159
+ :param from_timezone: The timezone to shift from. If no timezone is provided, uses the global
160
+ timezone variable set by the TimeUtil. A list of valid timezones can be found at
161
+ https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. May also accept a UTC offset in seconds.
162
+ :return: The epoch timestamp that would display as the same time in to_timezone as the current time in
163
+ from_timezone.
164
+ """
165
+ millis: int = TimeUtil.now_in_millis()
166
+ return TimeUtil.shift_millis(millis, to_timezone, from_timezone)
167
+
168
+ @staticmethod
169
+ def shift_millis(millis: int, to_timezone: str = "UTC", from_timezone: str | None = None) -> int:
170
+ """
171
+ Take a number of milliseconds for a time in from_timezone and output the epoch timestamp that would display that
172
+ same time in to_timezone. A use case for this is when dealing with static date fields to convert a provided
173
+ timestamp to the value necessary to display that timestamp in the same way when viewed in the static date field.
174
+
175
+ :param millis: The time in milliseconds to convert from.
176
+ :param to_timezone: The timezone to shift to. If not provided, uses UTC.
177
+ :param from_timezone: The timezone to shift from. If no timezone is provided, uses the global
178
+ timezone variable set by the TimeUtil. A list of valid timezones can be found at
179
+ https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. May also accept a UTC offset in seconds.
180
+ :return: The epoch timestamp that would display as the same time in to_timezone as the given time in
181
+ from_timezone.
182
+ """
183
+ to_offset: int = TimeUtil.__get_timezone_offset(to_timezone) * 1000
184
+ from_offset: int = TimeUtil.__get_timezone_offset(from_timezone) * 1000
185
+ return millis + from_offset - to_offset
186
+
187
+ @staticmethod
188
+ def shift_format(time_point: str, time_format: str, to_timezone: str = "UTC", from_timezone: str | None = None) \
189
+ -> int:
190
+ """
191
+ Take a timestamp for a time in from_timezone and output the epoch timestamp that would display that same time
192
+ in to_timezone. A use case for this is when dealing with static date fields to convert a provided timestamp to
193
+ the value necessary to display that timestamp in the same way when viewed in the static date field.
194
+
195
+ :param time_point: The time in some date/time format to convert from.
196
+ :param time_format: The format that the time_point is in. Documentation for how the time formatting works
197
+ can be found at https://docs.python.org/3.10/library/datetime.html#strftime-and-strptime-behavior
198
+ :param to_timezone: The timezone to shift to. If not provided, uses UTC.
199
+ :param from_timezone: The timezone to shift from. If no timezone is provided, uses the global
200
+ timezone variable set by the TimeUtil. A list of valid timezones can be found at
201
+ https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. May also accept a UTC offset in seconds.
202
+ :return: The epoch timestamp that would display as the same time in to_timezone as the given time in
203
+ from_timezone.
204
+ """
205
+ millis: int = TimeUtil.format_to_millis(time_point, time_format, from_timezone)
206
+ return TimeUtil.shift_millis(millis, to_timezone, from_timezone)
207
+
130
208
  # FR-46154: Create a function that determines if a string matches a time format.
131
209
  @staticmethod
132
210
  def str_matches_format(time_point: str, time_format: str) -> bool: