snowpark-checkpoints-configuration 0.1.3__py3-none-any.whl → 0.2.0__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.
@@ -13,10 +13,20 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
+ import logging
17
+
18
+
19
+ # Add a NullHandler to prevent logging messages from being output to
20
+ # sys.stderr if no logging configuration is provided.
21
+ logging.getLogger(__name__).addHandler(logging.NullHandler())
22
+
23
+ # ruff: noqa: E402
24
+
16
25
  from snowflake.snowpark_checkpoints_configuration.checkpoint_metadata import (
17
26
  CheckpointMetadata,
18
27
  )
19
28
 
29
+
20
30
  __all__ = [
21
31
  "CheckpointMetadata",
22
32
  ]
@@ -13,4 +13,4 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- __version__ = "0.1.3"
16
+ __version__ = "0.2.0"
@@ -12,8 +12,12 @@
12
12
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
+
16
+ import logging
15
17
  import os
16
18
 
19
+ from typing import Optional
20
+
17
21
  from snowflake.snowpark_checkpoints_configuration.model.checkpoints import (
18
22
  Checkpoint,
19
23
  Checkpoints,
@@ -21,6 +25,9 @@ from snowflake.snowpark_checkpoints_configuration.model.checkpoints import (
21
25
  from snowflake.snowpark_checkpoints_configuration.singleton import Singleton
22
26
 
23
27
 
28
+ LOGGER = logging.getLogger(__name__)
29
+
30
+
24
31
  class CheckpointMetadata(metaclass=Singleton):
25
32
 
26
33
  """CheckpointMetadata class.
@@ -33,21 +40,28 @@ class CheckpointMetadata(metaclass=Singleton):
33
40
 
34
41
  """
35
42
 
36
- def __init__(self, path: str = None):
37
- directory = path if path is not None else os.getcwd()
43
+ def __init__(self, path: Optional[str] = None):
38
44
  self.checkpoint_model: Checkpoints = Checkpoints(type="", pipelines=[])
45
+ directory = path if path is not None else os.getcwd()
39
46
  checkpoints_file = os.path.join(directory, "checkpoints.json")
40
47
  if os.path.exists(checkpoints_file):
41
- with open(checkpoints_file) as f:
42
- try:
48
+ LOGGER.info("Reading checkpoints file: '%s'", checkpoints_file)
49
+ try:
50
+ with open(checkpoints_file) as f:
43
51
  checkpoint_json = f.read()
44
52
  self.checkpoint_model = Checkpoints.model_validate_json(
45
53
  checkpoint_json
46
54
  )
47
- except Exception as e:
48
- raise Exception(
49
- f"Error reading checkpoints file: {checkpoints_file} \n {e}"
50
- ) from None
55
+ LOGGER.info(
56
+ "Successfully read and validated checkpoints file: '%s'",
57
+ checkpoints_file,
58
+ )
59
+ except Exception as e:
60
+ error_msg = f"An error occurred while reading the checkpoints file: '{checkpoints_file}'"
61
+ LOGGER.exception(error_msg)
62
+ raise Exception(f"{error_msg} \n {e}") from None
63
+ else:
64
+ LOGGER.warning("Checkpoints file not found: '%s'", checkpoints_file)
51
65
 
52
66
  def get_checkpoint(self, checkpoint_name: str) -> Checkpoint:
53
67
  """Get a checkpoint by its name.
@@ -13,6 +13,8 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
+ import logging
17
+
16
18
  from typing import Optional
17
19
 
18
20
  from pydantic import BaseModel, ConfigDict, field_validator
@@ -21,6 +23,9 @@ from pydantic.alias_generators import to_camel
21
23
  from snowflake.snowpark_checkpoints_configuration import checkpoint_name_utils
22
24
 
23
25
 
26
+ LOGGER = logging.getLogger(__name__)
27
+
28
+
24
29
  class Checkpoint(BaseModel):
25
30
 
26
31
  """Checkpoint model.
@@ -42,15 +47,19 @@ class Checkpoint(BaseModel):
42
47
  @field_validator("name", mode="before")
43
48
  @classmethod
44
49
  def normalize(cls, name: str) -> str:
50
+ LOGGER.debug("Normalizing checkpoint name: '%s'", name)
45
51
  normalized_name = checkpoint_name_utils.normalize_checkpoint_name(name)
52
+ LOGGER.debug("Checkpoint name was normalized to: '%s'", normalized_name)
46
53
  is_valid_checkpoint_name = checkpoint_name_utils.is_valid_checkpoint_name(
47
54
  normalized_name
48
55
  )
49
56
  if not is_valid_checkpoint_name:
50
- raise Exception(
51
- f"Invalid checkpoint name: {name} in checkpoints.json file. Checkpoint names must only contain "
52
- f"alphanumeric characters and underscores."
57
+ error_msg = (
58
+ f"Invalid checkpoint name: {name} in checkpoints.json file. "
59
+ f"Checkpoint names must only contain alphanumeric characters and underscores."
53
60
  )
61
+ LOGGER.error(error_msg)
62
+ raise Exception(error_msg)
54
63
 
55
64
  return normalized_name
56
65
 
@@ -93,8 +102,11 @@ class Checkpoints(BaseModel):
93
102
  _checkpoints = {}
94
103
 
95
104
  def _build_checkpoints_dict(self):
105
+ LOGGER.debug("Building checkpoints dictionary from pipelines.")
96
106
  for pipeline in self.pipelines:
107
+ LOGGER.debug("Processing pipeline: '%s'", pipeline.entry_point)
97
108
  for checkpoint in pipeline.checkpoints:
109
+ LOGGER.debug("Adding checkpoint: %s", checkpoint)
98
110
  self._checkpoints[checkpoint.name] = checkpoint
99
111
 
100
112
  def get_check_point(self, checkpoint_name: str) -> Checkpoint:
@@ -108,21 +120,35 @@ class Checkpoints(BaseModel):
108
120
  with the name set to the checkpoint_id.
109
121
 
110
122
  """
123
+ LOGGER.info("Fetching checkpoint: '%s'", checkpoint_name)
111
124
  if not self._checkpoints:
125
+ LOGGER.debug("Checkpoints dictionary is empty, building it...")
112
126
  self._build_checkpoints_dict()
113
127
 
114
128
  checkpoint = self._checkpoints.get(checkpoint_name)
115
129
  if len(self._checkpoints) == 0:
130
+ LOGGER.info(
131
+ "No checkpoints found, creating a new enabled checkpoint with name: '%s'",
132
+ checkpoint_name,
133
+ )
116
134
  checkpoint = Checkpoint(name=checkpoint_name, enabled=True)
117
135
  elif checkpoint is None:
136
+ LOGGER.info(
137
+ "Checkpoint not found, creating a new disabled checkpoint with name: '%s'",
138
+ checkpoint_name,
139
+ )
118
140
  checkpoint = Checkpoint(name=checkpoint_name, enabled=False)
141
+
142
+ LOGGER.debug("Returning checkpoint: %s", checkpoint)
119
143
  return checkpoint
120
144
 
121
145
  def add_checkpoint(self, checkpoint: Checkpoint) -> None:
122
146
  """Add a checkpoint to the checkpoints' dictionary.
123
147
 
124
- Args:.
148
+ Args:
125
149
  checkpoint (Checkpoint): The checkpoint object to add
126
150
 
127
151
  """
152
+ LOGGER.debug("Adding checkpoint: %s", checkpoint)
128
153
  self._checkpoints[checkpoint.name] = checkpoint
154
+ LOGGER.info("Checkpoint '%s' added successfully.", checkpoint.name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: snowpark-checkpoints-configuration
3
- Version: 0.1.3
3
+ Version: 0.2.0
4
4
  Summary: Migration tools for Snowpark
5
5
  Project-URL: Bug Tracker, https://github.com/snowflakedb/snowpark-checkpoints/issues
6
6
  Project-URL: Source code, https://github.com/snowflakedb/snowpark-checkpoints/
@@ -27,7 +27,7 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
27
27
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
28
  Requires-Python: <3.12,>=3.9
29
29
  Requires-Dist: pydantic>=1.8.2
30
- Requires-Dist: snowflake-snowpark-python==1.26.0
30
+ Requires-Dist: snowflake-snowpark-python>=1.23.0
31
31
  Provides-Extra: development
32
32
  Requires-Dist: coverage>=7.6.7; extra == 'development'
33
33
  Requires-Dist: hatchling==1.25.0; extra == 'development'
@@ -1,10 +1,10 @@
1
- snowflake/snowpark_checkpoints_configuration/__init__.py,sha256=ILSUJf0losOC1vPMWITsK0zv5NjccBy8wlgQd5-YJlU,756
2
- snowflake/snowpark_checkpoints_configuration/__version__.py,sha256=OfdAqrd8gnFI-pK7o_olRVrRKIWfQhQOoo_wR3u1s5s,632
3
- snowflake/snowpark_checkpoints_configuration/checkpoint_metadata.py,sha256=6V968CUQcYu0CnSHnJmP3Ccgmekfyfanh9JinH7UGOA,2207
1
+ snowflake/snowpark_checkpoints_configuration/__init__.py,sha256=xZ2oBwJeEso0laWYDaXQidGt_MdjgNsOZ1_0BcZcXvE,980
2
+ snowflake/snowpark_checkpoints_configuration/__version__.py,sha256=ajnGza8ucK69-PA8wEbHmWZxDwd3bsTm74yMKiIWNHY,632
3
+ snowflake/snowpark_checkpoints_configuration/checkpoint_metadata.py,sha256=vr60OMFW5PUR5BSBSi1PqiTRoKi4D64qxSUP5z1Lz4o,2692
4
4
  snowflake/snowpark_checkpoints_configuration/checkpoint_name_utils.py,sha256=WExQaZ4oL4otDCtM8kyGbf0Gn_v1a-tzM5j1p0wVDVg,1767
5
5
  snowflake/snowpark_checkpoints_configuration/singleton.py,sha256=7AgIHQBXVRvPBBCkmBplzkdrrm-xVWf_N8svzA2vF8E,836
6
- snowflake/snowpark_checkpoints_configuration/model/checkpoints.py,sha256=5OJfAU3oyQZoffOD01Pr1aNlghSKqZ6L-JAhggC0T5Y,3688
7
- snowpark_checkpoints_configuration-0.1.3.dist-info/METADATA,sha256=cAy9aOOcdmIRwCrYJCneqPerVel-T16dzQjr3TnqRWs,2724
8
- snowpark_checkpoints_configuration-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- snowpark_checkpoints_configuration-0.1.3.dist-info/licenses/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
10
- snowpark_checkpoints_configuration-0.1.3.dist-info/RECORD,,
6
+ snowflake/snowpark_checkpoints_configuration/model/checkpoints.py,sha256=O2x_iRQiw-UojjS770p9JX0JAy1mmBAA8WkzOaUaZ8U,4838
7
+ snowpark_checkpoints_configuration-0.2.0.dist-info/METADATA,sha256=qswqNR19zQcrSLRh_uAOiBQ-X4cvjtMEYuvVSOFjCT4,2724
8
+ snowpark_checkpoints_configuration-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ snowpark_checkpoints_configuration-0.2.0.dist-info/licenses/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
10
+ snowpark_checkpoints_configuration-0.2.0.dist-info/RECORD,,