snowpark-checkpoints-configuration 0.2.1__py3-none-any.whl → 0.3.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,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.2.1"
16
+ __version__ = "0.3.0"
@@ -18,6 +18,9 @@ import os
18
18
 
19
19
  from typing import Optional
20
20
 
21
+ from snowflake.snowpark_checkpoints_configuration.io_utils.io_file_manager import (
22
+ get_io_file_manager,
23
+ )
21
24
  from snowflake.snowpark_checkpoints_configuration.model.checkpoints import (
22
25
  Checkpoint,
23
26
  Checkpoints,
@@ -42,16 +45,13 @@ class CheckpointMetadata(metaclass=Singleton):
42
45
 
43
46
  def __init__(self, path: Optional[str] = None):
44
47
  self.checkpoint_model: Checkpoints = Checkpoints(type="", pipelines=[])
45
- directory = path if path is not None else os.getcwd()
48
+ directory = path if path is not None else get_io_file_manager().getcwd()
46
49
  checkpoints_file = os.path.join(directory, "checkpoints.json")
47
- if os.path.exists(checkpoints_file):
50
+ if get_io_file_manager().file_exists(checkpoints_file):
48
51
  LOGGER.info("Reading checkpoints file: '%s'", checkpoints_file)
49
52
  try:
50
- with open(checkpoints_file) as f:
51
- checkpoint_json = f.read()
52
- self.checkpoint_model = Checkpoints.model_validate_json(
53
- checkpoint_json
54
- )
53
+ checkpoint_json = get_io_file_manager().read(checkpoints_file)
54
+ self.checkpoint_model = Checkpoints.model_validate_json(checkpoint_json)
55
55
  LOGGER.info(
56
56
  "Successfully read and validated checkpoints file: '%s'",
57
57
  checkpoints_file,
@@ -0,0 +1,26 @@
1
+ # Copyright 2025 Snowflake Inc.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ __all__ = ["EnvStrategy", "IOFileManager", "IODefaultStrategy"]
17
+
18
+ from snowflake.snowpark_checkpoints_configuration.io_utils.io_env_strategy import (
19
+ EnvStrategy,
20
+ )
21
+ from snowflake.snowpark_checkpoints_configuration.io_utils.io_default_strategy import (
22
+ IODefaultStrategy,
23
+ )
24
+ from snowflake.snowpark_checkpoints_configuration.io_utils.io_file_manager import (
25
+ IOFileManager,
26
+ )
@@ -0,0 +1,34 @@
1
+ # Copyright 2025 Snowflake Inc.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ import os
17
+
18
+ from typing import Optional
19
+
20
+ from snowflake.snowpark_checkpoints_configuration.io_utils import EnvStrategy
21
+
22
+
23
+ class IODefaultStrategy(EnvStrategy):
24
+ def file_exists(self, path: str) -> bool:
25
+ return os.path.isfile(path)
26
+
27
+ def read(
28
+ self, file_path: str, mode: str = "r", encoding: Optional[str] = None
29
+ ) -> str:
30
+ with open(file_path, mode=mode, encoding=encoding) as file:
31
+ return file.read()
32
+
33
+ def getcwd(self) -> str:
34
+ return os.getcwd()
@@ -0,0 +1,62 @@
1
+ # Copyright 2025 Snowflake Inc.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ from abc import ABC, abstractmethod
17
+ from typing import Optional
18
+
19
+
20
+ class EnvStrategy(ABC):
21
+
22
+ """An abstract base class that defines methods for file and directory operations.
23
+
24
+ Subclasses should implement these methods to provide environment-specific behavior.
25
+ """
26
+
27
+ @abstractmethod
28
+ def file_exists(self, path: str) -> bool:
29
+ """Check if a file exists.
30
+
31
+ Args:
32
+ path: The path to the file.
33
+
34
+ Returns:
35
+ bool: True if the file exists, False otherwise.
36
+
37
+ """
38
+
39
+ @abstractmethod
40
+ def read(
41
+ self, file_path: str, mode: str = "r", encoding: Optional[str] = None
42
+ ) -> str:
43
+ """Read content from a file.
44
+
45
+ Args:
46
+ file_path: The path to the file to read from.
47
+ mode: The mode in which to open the file.
48
+ encoding: The encoding to use for reading the file.
49
+
50
+ Returns:
51
+ str: The content of the file.
52
+
53
+ """
54
+
55
+ @abstractmethod
56
+ def getcwd(self) -> str:
57
+ """Get the current working directory.
58
+
59
+ Returns:
60
+ str: The current working directory.
61
+
62
+ """
@@ -0,0 +1,57 @@
1
+ # Copyright 2025 Snowflake Inc.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ from typing import Optional
17
+
18
+ from snowflake.snowpark_checkpoints_configuration.io_utils import (
19
+ EnvStrategy,
20
+ IODefaultStrategy,
21
+ )
22
+ from snowflake.snowpark_checkpoints_configuration.singleton import Singleton
23
+
24
+
25
+ class IOFileManager(metaclass=Singleton):
26
+ def __init__(self, strategy: Optional[EnvStrategy] = None):
27
+ self.strategy = strategy or IODefaultStrategy()
28
+
29
+ def file_exists(self, path: str) -> bool:
30
+ return self.strategy.file_exists(path)
31
+
32
+ def read(
33
+ self, file_path: str, mode: str = "r", encoding: Optional[str] = None
34
+ ) -> str:
35
+ return self.strategy.read(file_path, mode, encoding)
36
+
37
+ def getcwd(self) -> str:
38
+ return self.strategy.getcwd()
39
+
40
+ def set_strategy(self, strategy: EnvStrategy):
41
+ """Set the strategy for file and directory operations.
42
+
43
+ Args:
44
+ strategy (EnvStrategy): The strategy to use for file and directory operations.
45
+
46
+ """
47
+ self.strategy = strategy
48
+
49
+
50
+ def get_io_file_manager():
51
+ """Get the singleton instance of IOFileManager.
52
+
53
+ Returns:
54
+ IOFileManager: The singleton instance of IOFileManager.
55
+
56
+ """
57
+ return IOFileManager()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: snowpark-checkpoints-configuration
3
- Version: 0.2.1
3
+ Version: 0.3.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/
@@ -29,6 +29,7 @@ Requires-Python: <3.12,>=3.9
29
29
  Requires-Dist: pydantic>=1.8.2
30
30
  Requires-Dist: snowflake-snowpark-python>=1.23.0
31
31
  Provides-Extra: development
32
+ Requires-Dist: certifi==2025.1.31; extra == 'development'
32
33
  Requires-Dist: coverage>=7.6.7; extra == 'development'
33
34
  Requires-Dist: hatchling==1.25.0; extra == 'development'
34
35
  Requires-Dist: pre-commit>=4.0.1; extra == 'development'
@@ -0,0 +1,14 @@
1
+ snowflake/snowpark_checkpoints_configuration/__init__.py,sha256=xZ2oBwJeEso0laWYDaXQidGt_MdjgNsOZ1_0BcZcXvE,980
2
+ snowflake/snowpark_checkpoints_configuration/__version__.py,sha256=kbbDnlkY7JOLNHvfWYkCO_mOBOV9GniMGdxYoQpLhyg,632
3
+ snowflake/snowpark_checkpoints_configuration/checkpoint_metadata.py,sha256=fdmZpZxzqwtYfCjwjkl_9M8Z1hY04f_vE05HfGVRQc4,2773
4
+ snowflake/snowpark_checkpoints_configuration/checkpoint_name_utils.py,sha256=Xc4k3JU6A96-79VFRR8NrNAUPeO3V1DEAhngg-hLlU4,1787
5
+ snowflake/snowpark_checkpoints_configuration/singleton.py,sha256=7AgIHQBXVRvPBBCkmBplzkdrrm-xVWf_N8svzA2vF8E,836
6
+ snowflake/snowpark_checkpoints_configuration/io_utils/__init__.py,sha256=UgACTfonQw5bMAAuU_CrtVTzVVKxxK6NEDOogNl2qJM,996
7
+ snowflake/snowpark_checkpoints_configuration/io_utils/io_default_strategy.py,sha256=TX0xhezFmO5f37SsNP8nhsfAfRWJ2YwYPOE_pefJvsg,1113
8
+ snowflake/snowpark_checkpoints_configuration/io_utils/io_env_strategy.py,sha256=h6gjwBqOhyJHxAvWa7kL4jvyqF31ssTWGkQCAH99rd8,1735
9
+ snowflake/snowpark_checkpoints_configuration/io_utils/io_file_manager.py,sha256=H_xNLycfia2R_35xF1ery41i1BqFzysEuQjkL5sZeEs,1782
10
+ snowflake/snowpark_checkpoints_configuration/model/checkpoints.py,sha256=R1L9kA6rhZxftw6iq7p4FwswcrJvU8HRn0XOkv6bRJA,4852
11
+ snowpark_checkpoints_configuration-0.3.0.dist-info/METADATA,sha256=Bjd-RHBmSKluYnJGbrsNEggmPwgJacvGGhBESZHT1i4,2782
12
+ snowpark_checkpoints_configuration-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
+ snowpark_checkpoints_configuration-0.3.0.dist-info/licenses/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
14
+ snowpark_checkpoints_configuration-0.3.0.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- snowflake/snowpark_checkpoints_configuration/__init__.py,sha256=xZ2oBwJeEso0laWYDaXQidGt_MdjgNsOZ1_0BcZcXvE,980
2
- snowflake/snowpark_checkpoints_configuration/__version__.py,sha256=jEnm4p_P4FqdYsTq3hnGQnhLZ4KwL0_Ew8fDF8BRL98,632
3
- snowflake/snowpark_checkpoints_configuration/checkpoint_metadata.py,sha256=vr60OMFW5PUR5BSBSi1PqiTRoKi4D64qxSUP5z1Lz4o,2692
4
- snowflake/snowpark_checkpoints_configuration/checkpoint_name_utils.py,sha256=Xc4k3JU6A96-79VFRR8NrNAUPeO3V1DEAhngg-hLlU4,1787
5
- snowflake/snowpark_checkpoints_configuration/singleton.py,sha256=7AgIHQBXVRvPBBCkmBplzkdrrm-xVWf_N8svzA2vF8E,836
6
- snowflake/snowpark_checkpoints_configuration/model/checkpoints.py,sha256=R1L9kA6rhZxftw6iq7p4FwswcrJvU8HRn0XOkv6bRJA,4852
7
- snowpark_checkpoints_configuration-0.2.1.dist-info/METADATA,sha256=13FFoejcxLnf6xyX_NG7bpqVvWs3rMYNTcdhPqfRszQ,2724
8
- snowpark_checkpoints_configuration-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- snowpark_checkpoints_configuration-0.2.1.dist-info/licenses/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
10
- snowpark_checkpoints_configuration-0.2.1.dist-info/RECORD,,