caketool 0.1.1__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.
caketool-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Real Python
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ include src/reader/*.toml
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.1
2
+ Name: caketool
3
+ Version: 0.1.1
4
+ Summary: Common tools for MLOps
5
+ Author-email: Khoi Do <khoi.do@cake.vn>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2018 Real Python
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/cake-digital-bank
29
+ Keywords: cake,ds,mlops
30
+ Classifier: License :: OSI Approved :: MIT License
31
+ Classifier: Programming Language :: Python
32
+ Classifier: Programming Language :: Python :: 3
33
+ Requires-Python: >=3.7
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: google-cloud-aiplatform
37
+ Requires-Dist: google-cloud-storage
38
+
39
+ ```bash
40
+ conda create -n caketool
41
+ conda activate caketool
42
+ python -m pip install pip-tools bumpver build twine
43
+ pip-compile pyproject.toml
44
+ pip-sync
45
+
46
+ bumpver update --major # Increment the MAJOR version when you make incompatible API changes.
47
+ bumpver update --minor # Increment the MINOR version when you add functionality in a backwards compatible manner.
48
+ bumpver update --patch # Increment the PATCH version when you make backwards compatible bug fixes.
49
+ python -m pip install -e . # Install on local machine
50
+ ```
@@ -0,0 +1,12 @@
1
+ ```bash
2
+ conda create -n caketool
3
+ conda activate caketool
4
+ python -m pip install pip-tools bumpver build twine
5
+ pip-compile pyproject.toml
6
+ pip-sync
7
+
8
+ bumpver update --major # Increment the MAJOR version when you make incompatible API changes.
9
+ bumpver update --minor # Increment the MINOR version when you add functionality in a backwards compatible manner.
10
+ bumpver update --patch # Increment the PATCH version when you make backwards compatible bug fixes.
11
+ python -m pip install -e . # Install on local machine
12
+ ```
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "caketool"
7
+ version = "0.1.1"
8
+ description = "Common tools for MLOps"
9
+ readme = "README.md"
10
+ authors = [{ name = "Khoi Do", email = "khoi.do@cake.vn" }]
11
+ license = { file = "LICENSE" }
12
+ classifiers = [
13
+ "License :: OSI Approved :: MIT License",
14
+ "Programming Language :: Python",
15
+ "Programming Language :: Python :: 3",
16
+ ]
17
+ keywords = ["cake", "ds", "mlops"]
18
+ dependencies = ["google-cloud-aiplatform", "google-cloud-storage"]
19
+ requires-python = ">=3.7"
20
+
21
+ # [project.optional-dependencies]
22
+ # optional = ["build", "twine"]
23
+
24
+ [project.scripts]
25
+ caketool = "caketool.__main__:main"
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/cake-digital-bank"
29
+
30
+
31
+ [tool.bumpver]
32
+ current_version = "0.1.1"
33
+ version_pattern = "MAJOR.MINOR.PATCH"
34
+ commit_message = "bump version {old_version} -> {new_version}"
35
+ commit = true
36
+ tag = true
37
+ push = false
38
+
39
+ [tool.bumpver.file_patterns]
40
+ "pyproject.toml" = ['current_version = "{version}"', 'version = "{version}"']
41
+ "src/caketool/__init__.py" = ["{version}"]
42
+ "src/caketool/__main__.py" = ["- caketool v{version}"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ __version__ = "0.1.1"
@@ -0,0 +1,7 @@
1
+ """
2
+ - caketool v0.1.1
3
+ """
4
+
5
+
6
+ def main():
7
+ print("Cake DS Team")
@@ -0,0 +1 @@
1
+ from .experiment_tracker import ExperimentTracker
@@ -0,0 +1,66 @@
1
+ from typing import Dict, Union
2
+ from google.cloud import aiplatform, storage
3
+
4
+
5
+ class ExperimentTracker:
6
+ def __init__(
7
+ self,
8
+ project: str,
9
+ location: str,
10
+ experiment_name: str,
11
+ experiment_run_name: str,
12
+ bucket_name: str,
13
+ experiment_description: str = None,
14
+ experiment_tensorboard: bool = False,
15
+ ) -> None:
16
+ self.project = project
17
+ self.location = location
18
+ self.experiment_name = experiment_name
19
+ self.experiment_description = experiment_description
20
+ self.experiment_tensorboard = experiment_tensorboard
21
+ self.experiment_run_name = experiment_run_name
22
+ self.bucket_name = bucket_name
23
+
24
+ aiplatform.init(
25
+ project=self.project,
26
+ location=self.location,
27
+ experiment=self.experiment_name,
28
+ experiment_description=self.experiment_description,
29
+ experiment_tensorboard=self.experiment_tensorboard,
30
+ staging_bucket=self.bucket_name,
31
+ )
32
+
33
+ self.experiment_run = aiplatform.start_run(self.experiment_run_name)
34
+ self.execution = aiplatform.start_execution(
35
+ display_name="Experiment Tracking",
36
+ schema_title="system.ContainerExecution"
37
+ )
38
+ self.gs_client = storage.Client(project=self.project)
39
+ self.gc_bucket = storage.Bucket(self.gs_client, self.bucket_name)
40
+
41
+ def log_params(self, params: Dict[str, Union[float, int, str]]):
42
+ aiplatform.log_params(params)
43
+
44
+ def log_metrics(self, metrics: Dict[str, Union[float, int, str]]):
45
+ aiplatform.log_metrics(metrics)
46
+
47
+ def log_file(self, filename, artifact_id):
48
+ blob_name = f"{self.experiment_name}-{self.experiment_run_name}-{artifact_id}"
49
+ blob = self.gc_bucket.blob(blob_name)
50
+ uri = "gs://" + storage.Blob.path_helper(self.bucket_name, blob_name)
51
+ if blob.exists():
52
+ raise f"{uri} existed! (Can not overwrite)"
53
+ blob.upload_from_filename(filename)
54
+ artifact = aiplatform.Artifact.create(
55
+ uri=uri, schema_title="system.Artifact")
56
+ self.experiment_run._metadata_node.add_artifacts_and_executions(
57
+ artifact_resource_names=[artifact.resource_name])
58
+
59
+ def __enter__(self):
60
+ self.execution.__enter__()
61
+ self.experiment_run.__enter__()
62
+ return self
63
+
64
+ def __exit__(self, exc_type, exc_value, exc_traceback):
65
+ self.execution.__exit__(exc_type, exc_value, exc_traceback)
66
+ self.experiment_run.__exit__(exc_type, exc_value, exc_traceback)
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.1
2
+ Name: caketool
3
+ Version: 0.1.1
4
+ Summary: Common tools for MLOps
5
+ Author-email: Khoi Do <khoi.do@cake.vn>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2018 Real Python
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/cake-digital-bank
29
+ Keywords: cake,ds,mlops
30
+ Classifier: License :: OSI Approved :: MIT License
31
+ Classifier: Programming Language :: Python
32
+ Classifier: Programming Language :: Python :: 3
33
+ Requires-Python: >=3.7
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: google-cloud-aiplatform
37
+ Requires-Dist: google-cloud-storage
38
+
39
+ ```bash
40
+ conda create -n caketool
41
+ conda activate caketool
42
+ python -m pip install pip-tools bumpver build twine
43
+ pip-compile pyproject.toml
44
+ pip-sync
45
+
46
+ bumpver update --major # Increment the MAJOR version when you make incompatible API changes.
47
+ bumpver update --minor # Increment the MINOR version when you add functionality in a backwards compatible manner.
48
+ bumpver update --patch # Increment the PATCH version when you make backwards compatible bug fixes.
49
+ python -m pip install -e . # Install on local machine
50
+ ```
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ src/caketool/__init__.py
6
+ src/caketool/__main__.py
7
+ src/caketool.egg-info/PKG-INFO
8
+ src/caketool.egg-info/SOURCES.txt
9
+ src/caketool.egg-info/dependency_links.txt
10
+ src/caketool.egg-info/entry_points.txt
11
+ src/caketool.egg-info/requires.txt
12
+ src/caketool.egg-info/top_level.txt
13
+ src/caketool/experiment/__init__.py
14
+ src/caketool/experiment/experiment_tracker.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ caketool = caketool.__main__:main
@@ -0,0 +1,2 @@
1
+ google-cloud-aiplatform
2
+ google-cloud-storage
@@ -0,0 +1 @@
1
+ caketool