aigear 0.0.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.
Files changed (73) hide show
  1. aigear-0.0.1/LICENSE +21 -0
  2. aigear-0.0.1/PKG-INFO +195 -0
  3. aigear-0.0.1/README.md +126 -0
  4. aigear-0.0.1/pyproject.toml +91 -0
  5. aigear-0.0.1/setup.cfg +4 -0
  6. aigear-0.0.1/src/aigear/__init__.py +27 -0
  7. aigear-0.0.1/src/aigear/_version.py +1 -0
  8. aigear-0.0.1/src/aigear/cli/__init__.py +0 -0
  9. aigear-0.0.1/src/aigear/cli/artifacts_image.py +24 -0
  10. aigear-0.0.1/src/aigear/cli/gcp_cli.py +6 -0
  11. aigear-0.0.1/src/aigear/cli/grpc_service.py +23 -0
  12. aigear-0.0.1/src/aigear/cli/project_cli.py +33 -0
  13. aigear-0.0.1/src/aigear/cli/scheduler.py +19 -0
  14. aigear-0.0.1/src/aigear/cli/task_running.py +33 -0
  15. aigear-0.0.1/src/aigear/common/__init__.py +16 -0
  16. aigear-0.0.1/src/aigear/common/config.py +59 -0
  17. aigear-0.0.1/src/aigear/common/dynamic_type.py +81 -0
  18. aigear-0.0.1/src/aigear/common/logger.py +105 -0
  19. aigear-0.0.1/src/aigear/common/schema/__init__.py +0 -0
  20. aigear-0.0.1/src/aigear/common/schema/bucket_schema.py +27 -0
  21. aigear-0.0.1/src/aigear/common/schema/config_schema.py +84 -0
  22. aigear-0.0.1/src/aigear/common/secretmanager.py +18 -0
  23. aigear-0.0.1/src/aigear/common/sh.py +48 -0
  24. aigear-0.0.1/src/aigear/db/__init__.py +0 -0
  25. aigear-0.0.1/src/aigear/db/bucket.py +80 -0
  26. aigear-0.0.1/src/aigear/db/mongodb.py +36 -0
  27. aigear-0.0.1/src/aigear/deploy/__init__.py +0 -0
  28. aigear-0.0.1/src/aigear/deploy/common/__init__.py +0 -0
  29. aigear-0.0.1/src/aigear/deploy/common/helm_chart.py +52 -0
  30. aigear-0.0.1/src/aigear/deploy/gcp/__init__.py +6 -0
  31. aigear-0.0.1/src/aigear/deploy/gcp/artifacts_image.py +68 -0
  32. aigear-0.0.1/src/aigear/deploy/gcp/grpc_gcp_deploy.py +70 -0
  33. aigear-0.0.1/src/aigear/deploy/gcp/scheduler.py +189 -0
  34. aigear-0.0.1/src/aigear/deploy/local/__init__.py +0 -0
  35. aigear-0.0.1/src/aigear/deploy/local/grpc_local_deploy.py +68 -0
  36. aigear-0.0.1/src/aigear/infrastructure/__init__.py +5 -0
  37. aigear-0.0.1/src/aigear/infrastructure/gcp/__init__.py +5 -0
  38. aigear-0.0.1/src/aigear/infrastructure/gcp/artifacts.py +56 -0
  39. aigear-0.0.1/src/aigear/infrastructure/gcp/bucket.py +70 -0
  40. aigear-0.0.1/src/aigear/infrastructure/gcp/build.py +84 -0
  41. aigear-0.0.1/src/aigear/infrastructure/gcp/constant.py +1 -0
  42. aigear-0.0.1/src/aigear/infrastructure/gcp/function/index.js +201 -0
  43. aigear-0.0.1/src/aigear/infrastructure/gcp/function/package.json +9 -0
  44. aigear-0.0.1/src/aigear/infrastructure/gcp/function.py +117 -0
  45. aigear-0.0.1/src/aigear/infrastructure/gcp/iam.py +112 -0
  46. aigear-0.0.1/src/aigear/infrastructure/gcp/infra.py +467 -0
  47. aigear-0.0.1/src/aigear/infrastructure/gcp/kubernetes.py +79 -0
  48. aigear-0.0.1/src/aigear/infrastructure/gcp/pre_vm_image.py +306 -0
  49. aigear-0.0.1/src/aigear/infrastructure/gcp/pub_sub.py +80 -0
  50. aigear-0.0.1/src/aigear/project.py +90 -0
  51. aigear-0.0.1/src/aigear/service/__init__.py +0 -0
  52. aigear-0.0.1/src/aigear/service/grpc/__init__.py +7 -0
  53. aigear-0.0.1/src/aigear/service/grpc/compile_proto.py +36 -0
  54. aigear-0.0.1/src/aigear/service/grpc/grpc_package/__init__.py +0 -0
  55. aigear-0.0.1/src/aigear/service/grpc/grpc_package/grpc_features.py +47 -0
  56. aigear-0.0.1/src/aigear/service/grpc/grpc_package/grpc_ml_module.py +31 -0
  57. aigear-0.0.1/src/aigear/service/grpc/grpc_service.py +145 -0
  58. aigear-0.0.1/src/aigear/service/grpc/protos/__init__.py +0 -0
  59. aigear-0.0.1/src/aigear/service/grpc/protos/grpc_pb2.py +31 -0
  60. aigear-0.0.1/src/aigear/service/grpc/protos/grpc_pb2_grpc.py +66 -0
  61. aigear-0.0.1/src/aigear/template/Dockerfile +18 -0
  62. aigear-0.0.1/src/aigear/template/__init__.py +0 -0
  63. aigear-0.0.1/src/aigear/template/cloudbuild.yaml +25 -0
  64. aigear-0.0.1/src/aigear/template/docker-compose.yml +23 -0
  65. aigear-0.0.1/src/aigear/template/env.sample.json +117 -0
  66. aigear-0.0.1/src/aigear/template/grpc/Dockerfile +17 -0
  67. aigear-0.0.1/src/aigear/template/grpc/docker-compose.yml +16 -0
  68. aigear-0.0.1/src/aigear.egg-info/PKG-INFO +195 -0
  69. aigear-0.0.1/src/aigear.egg-info/SOURCES.txt +71 -0
  70. aigear-0.0.1/src/aigear.egg-info/dependency_links.txt +1 -0
  71. aigear-0.0.1/src/aigear.egg-info/entry_points.txt +7 -0
  72. aigear-0.0.1/src/aigear.egg-info/requires.txt +25 -0
  73. aigear-0.0.1/src/aigear.egg-info/top_level.txt +1 -0
aigear-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 RetailAI Inc.
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.
aigear-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.4
2
+ Name: aigear
3
+ Version: 0.0.1
4
+ Summary: Machine learning microservices based on gRPC
5
+ Author: Retail AI Groups Inc.
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 RetailAI Inc.
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/retail-ai-inc/gear
29
+ Project-URL: Repository, https://github.com/retail-ai-inc/aigear.git
30
+ Project-URL: Issues, https://github.com/retail-ai-inc/aigear/issues
31
+ Keywords: MLOps,AI,ML,Model Serving,Model Deployment,Model Training
32
+ Classifier: Intended Audience :: Science/Research
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: Programming Language :: Python :: 3 :: Only
35
+ Classifier: Programming Language :: Python :: 3.8
36
+ Classifier: Programming Language :: Python :: 3.9
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: License :: OSI Approved :: MIT License
41
+ Classifier: Operating System :: Microsoft :: Windows
42
+ Classifier: Operating System :: Unix
43
+ Classifier: Operating System :: MacOS
44
+ Requires-Python: >=3.8
45
+ Description-Content-Type: text/markdown
46
+ License-File: LICENSE
47
+ Requires-Dist: aigear[common]
48
+ Requires-Dist: aigear[docker]
49
+ Requires-Dist: aigear[msgrpc]
50
+ Requires-Dist: aigear[gcp]
51
+ Provides-Extra: common
52
+ Requires-Dist: tabulate>=0.9; extra == "common"
53
+ Requires-Dist: cloudpickle>=2.0.0; extra == "common"
54
+ Requires-Dist: pydantic>=2.11.9; extra == "common"
55
+ Requires-Dist: datamodel_code_generator>=0.34.0; extra == "common"
56
+ Provides-Extra: docker
57
+ Requires-Dist: docker>=6.13; extra == "docker"
58
+ Provides-Extra: msgrpc
59
+ Requires-Dist: grpcio>=1.54.2; extra == "msgrpc"
60
+ Requires-Dist: protobuf>=4.23.3; extra == "msgrpc"
61
+ Requires-Dist: grpcio-health-checking>=1.56.0; extra == "msgrpc"
62
+ Requires-Dist: sentry-sdk>=1.29.2; extra == "msgrpc"
63
+ Provides-Extra: gcp
64
+ Requires-Dist: google-cloud-logging>=3.0.0; extra == "gcp"
65
+ Requires-Dist: google-cloud-secret-manager>=2.24.0; extra == "gcp"
66
+ Requires-Dist: google-cloud-storage>=3.2.0; extra == "gcp"
67
+ Requires-Dist: google-cloud-compute>=1.38.0; extra == "gcp"
68
+ Dynamic: license-file
69
+
70
+ # Aigear
71
+ Aigear is an MLOps work orchestration framework that is serverless and aims to help you build pipelines more quickly.
72
+ It will not change the programming style of Python and provides an optimized out-of-the-box toolbox.
73
+
74
+ Aigear believes that everything is a task, and it allows you to make any extensions according to the task.
75
+ Within Aigear, it performs topology analysis on tasks to achieve optimal parallel execution.
76
+
77
+ You need to note that aigear only executes functions created by yourself in parallel.
78
+
79
+ ## Getting started
80
+
81
+ Aigear requires Python 3.8 or later. To install the latest or upgrade to the latest version of Aigear, run the following command:
82
+
83
+ ```bash
84
+ pip install -U aigear
85
+ ```
86
+
87
+ With just two decorators(`@task` and `@workflow`), you can create a pipeline.
88
+ Please refer to `/aigear/example/pipeline`.
89
+
90
+ Here is an example of iris classification:
91
+ ```python
92
+ from sklearn.datasets import load_iris
93
+ from sklearn.model_selection import train_test_split
94
+ from sklearn.linear_model import LogisticRegression
95
+ from sklearn.metrics import accuracy_score
96
+ from aigear.pipeline import workflow, task
97
+ import pickle
98
+ import json
99
+ import os
100
+
101
+
102
+ @task
103
+ def load_data():
104
+ iris = load_iris()
105
+ return iris
106
+
107
+
108
+ @task
109
+ def split_dataset(iris):
110
+ X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=42)
111
+ return X_train, X_test, y_train, y_test
112
+
113
+
114
+ @task
115
+ def fit_model(X_train, y_train):
116
+ clf = LogisticRegression(random_state=0, max_iter=1000, solver="lbfgs")
117
+ model = clf.fit(X_train, y_train)
118
+ return model
119
+
120
+
121
+ @task
122
+ def evaluate(clf, X_test, y_test):
123
+ y_pred = clf.predict(X_test)
124
+ accuracy = accuracy_score(y_test, y_pred)
125
+ return y_pred, accuracy
126
+
127
+
128
+ @task
129
+ def get_env_variables():
130
+ with open("env.json", "r") as f:
131
+ env = json.load(f)
132
+ model_path = env.get("grpc", {}).get("servers", {}).get("demo", {}).get("modelPath")
133
+ return model_path
134
+
135
+
136
+ @task
137
+ def save_model(model, model_path):
138
+ with open(model_path, "wb") as md:
139
+ pickle.dump(model, md)
140
+
141
+
142
+ @workflow
143
+ def my_pipeline():
144
+ iris = load_data()
145
+ X_train, X_test, y_train, y_test = split_dataset(iris)
146
+ model = fit_model(X_train, y_train)
147
+ y_pred, accuracy = evaluate(model, X_test, y_test)
148
+ print("accuracy:", accuracy)
149
+
150
+ model_path = get_env_variables()
151
+ save_model(model, model_path)
152
+
153
+
154
+ if __name__ == '__main__':
155
+ # # Run the pipeline directly
156
+ # my_pipeline()
157
+
158
+ # Run pipeline in parallel
159
+ my_pipeline.run_in_executor()
160
+ ```
161
+
162
+ Similarly, the task can also be executed in two ways.
163
+ ```python
164
+ if __name__ == "__main__":
165
+ # # Run the pipeline directly
166
+ # load_data()
167
+
168
+ # Run pipeline in parallel
169
+ load_data.run_in_executor()
170
+ ```
171
+
172
+ If you want to deploy a pipeline or create a model service in local docker, it's quite simple.
173
+
174
+ ```python
175
+ if __name__ == '__main__':
176
+ current_directory = os.getcwd()
177
+ volumes = {
178
+ current_directory: {'bind': "/pipeline", 'mode': 'rw'}
179
+ }
180
+ hostname = "demo-host"
181
+ ports = {'50051/tcp': 50051}
182
+ service_dir = "demo"
183
+
184
+ my_pipeline.deploy(
185
+ volumes=volumes,
186
+ skip_build_image=False
187
+ ).to_service(
188
+ hostname=hostname,
189
+ ports=ports,
190
+ volumes=volumes,
191
+ tag=service_dir,
192
+ )
193
+ ```
194
+
195
+
aigear-0.0.1/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # Aigear
2
+ Aigear is an MLOps work orchestration framework that is serverless and aims to help you build pipelines more quickly.
3
+ It will not change the programming style of Python and provides an optimized out-of-the-box toolbox.
4
+
5
+ Aigear believes that everything is a task, and it allows you to make any extensions according to the task.
6
+ Within Aigear, it performs topology analysis on tasks to achieve optimal parallel execution.
7
+
8
+ You need to note that aigear only executes functions created by yourself in parallel.
9
+
10
+ ## Getting started
11
+
12
+ Aigear requires Python 3.8 or later. To install the latest or upgrade to the latest version of Aigear, run the following command:
13
+
14
+ ```bash
15
+ pip install -U aigear
16
+ ```
17
+
18
+ With just two decorators(`@task` and `@workflow`), you can create a pipeline.
19
+ Please refer to `/aigear/example/pipeline`.
20
+
21
+ Here is an example of iris classification:
22
+ ```python
23
+ from sklearn.datasets import load_iris
24
+ from sklearn.model_selection import train_test_split
25
+ from sklearn.linear_model import LogisticRegression
26
+ from sklearn.metrics import accuracy_score
27
+ from aigear.pipeline import workflow, task
28
+ import pickle
29
+ import json
30
+ import os
31
+
32
+
33
+ @task
34
+ def load_data():
35
+ iris = load_iris()
36
+ return iris
37
+
38
+
39
+ @task
40
+ def split_dataset(iris):
41
+ X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=42)
42
+ return X_train, X_test, y_train, y_test
43
+
44
+
45
+ @task
46
+ def fit_model(X_train, y_train):
47
+ clf = LogisticRegression(random_state=0, max_iter=1000, solver="lbfgs")
48
+ model = clf.fit(X_train, y_train)
49
+ return model
50
+
51
+
52
+ @task
53
+ def evaluate(clf, X_test, y_test):
54
+ y_pred = clf.predict(X_test)
55
+ accuracy = accuracy_score(y_test, y_pred)
56
+ return y_pred, accuracy
57
+
58
+
59
+ @task
60
+ def get_env_variables():
61
+ with open("env.json", "r") as f:
62
+ env = json.load(f)
63
+ model_path = env.get("grpc", {}).get("servers", {}).get("demo", {}).get("modelPath")
64
+ return model_path
65
+
66
+
67
+ @task
68
+ def save_model(model, model_path):
69
+ with open(model_path, "wb") as md:
70
+ pickle.dump(model, md)
71
+
72
+
73
+ @workflow
74
+ def my_pipeline():
75
+ iris = load_data()
76
+ X_train, X_test, y_train, y_test = split_dataset(iris)
77
+ model = fit_model(X_train, y_train)
78
+ y_pred, accuracy = evaluate(model, X_test, y_test)
79
+ print("accuracy:", accuracy)
80
+
81
+ model_path = get_env_variables()
82
+ save_model(model, model_path)
83
+
84
+
85
+ if __name__ == '__main__':
86
+ # # Run the pipeline directly
87
+ # my_pipeline()
88
+
89
+ # Run pipeline in parallel
90
+ my_pipeline.run_in_executor()
91
+ ```
92
+
93
+ Similarly, the task can also be executed in two ways.
94
+ ```python
95
+ if __name__ == "__main__":
96
+ # # Run the pipeline directly
97
+ # load_data()
98
+
99
+ # Run pipeline in parallel
100
+ load_data.run_in_executor()
101
+ ```
102
+
103
+ If you want to deploy a pipeline or create a model service in local docker, it's quite simple.
104
+
105
+ ```python
106
+ if __name__ == '__main__':
107
+ current_directory = os.getcwd()
108
+ volumes = {
109
+ current_directory: {'bind': "/pipeline", 'mode': 'rw'}
110
+ }
111
+ hostname = "demo-host"
112
+ ports = {'50051/tcp': 50051}
113
+ service_dir = "demo"
114
+
115
+ my_pipeline.deploy(
116
+ volumes=volumes,
117
+ skip_build_image=False
118
+ ).to_service(
119
+ hostname=hostname,
120
+ ports=ports,
121
+ volumes=volumes,
122
+ tag=service_dir,
123
+ )
124
+ ```
125
+
126
+
@@ -0,0 +1,91 @@
1
+ [build-system]
2
+ requires = ["setuptools>=46.4.0", "wheel>=0.36.2"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "aigear"
7
+ version = "0.0.1"
8
+ #dynamic = ["version"]
9
+ description = "Machine learning microservices based on gRPC"
10
+ keywords = ["MLOps", "AI", "ML", "Model Serving", "Model Deployment", "Model Training"]
11
+ authors = [{ name = "Retail AI Groups Inc." }]
12
+ readme = "README.md"
13
+ license = { file = 'LICENSE' }
14
+ requires-python = ">=3.8"
15
+ classifiers = [
16
+ "Intended Audience :: Science/Research",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3 :: Only",
19
+ "Programming Language :: Python :: 3.8",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "License :: OSI Approved :: MIT License",
25
+ "Operating System :: Microsoft :: Windows",
26
+ "Operating System :: Unix",
27
+ "Operating System :: MacOS",
28
+ ]
29
+ dependencies = [
30
+ "aigear[common]",
31
+ "aigear[docker]",
32
+ "aigear[msgrpc]",
33
+ "aigear[gcp]",
34
+ ]
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/retail-ai-inc/gear"
38
+ Repository = "https://github.com/retail-ai-inc/aigear.git"
39
+ Issues = "https://github.com/retail-ai-inc/aigear/issues"
40
+
41
+ [project.optional-dependencies]
42
+ common = [
43
+ "tabulate>=0.9",
44
+ "cloudpickle>=2.0.0",
45
+ "pydantic>=2.11.9",
46
+ "datamodel_code_generator>=0.34.0",
47
+ ]
48
+ docker = [
49
+ "docker>=6.13",
50
+ ]
51
+ msgrpc = [
52
+ "grpcio>=1.54.2",
53
+ "protobuf>=4.23.3",
54
+ "grpcio-health-checking>=1.56.0",
55
+ "sentry-sdk>=1.29.2",
56
+ ]
57
+ gcp = [
58
+ "google-cloud-logging>=3.0.0",
59
+ "google-cloud-secret-manager>=2.24.0",
60
+ "google-cloud-storage>=3.2.0",
61
+ "google-cloud-compute>=1.38.0"
62
+ ]
63
+
64
+ [project.scripts]
65
+ aigear-init = "aigear.cli.project_cli:project_init"
66
+ aigear-gcp-infra = "aigear.cli.gcp_cli:gcp_infra_init"
67
+ aigear-workflow = "aigear.cli.task_running:task_run"
68
+ aigear-scheduler = "aigear.cli.scheduler:scheduler_init"
69
+ artifacts-image-create = "aigear.cli.artifacts_image:artifacts_image_init"
70
+ aigear-grpc = "aigear.cli.grpc_service:grpc_run"
71
+
72
+ [tool.setuptools.packages.find]
73
+ where = ["src"]
74
+ include = [
75
+ "aigear*",
76
+ ]
77
+
78
+ [tool.setuptools.package-data]
79
+ "aigear" = [
80
+ "template/*",
81
+ "template/**/*",
82
+ "common/*",
83
+ "common/**/*",
84
+ "**/*.yaml",
85
+ "**/*.yml",
86
+ "**/*.json",
87
+ "**/*.toml",
88
+ "**/*.js",
89
+ "**/*.md",
90
+ "**/Dockerfile",
91
+ ]
aigear-0.0.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,27 @@
1
+ from .project import Project
2
+ from ._version import __version__
3
+ from .common import (
4
+ Logging,
5
+ generate_schema,
6
+ generate_schema_for_json,
7
+ SecretManager,
8
+ )
9
+ from aigear.infrastructure import Infra
10
+ from aigear.deploy.gcp.scheduler import create_scheduler
11
+ from aigear.common import AigearConfig
12
+
13
+
14
+ __all__ = [
15
+ "Logging",
16
+ "generate_schema",
17
+ "generate_schema_for_json",
18
+ "SecretManager",
19
+ "Infra",
20
+ ]
21
+
22
+ __all__.extend(
23
+ [
24
+ Project,
25
+ __version__,
26
+ ]
27
+ )
@@ -0,0 +1 @@
1
+ __version__ = "0.0.1"
File without changes
@@ -0,0 +1,24 @@
1
+ import argparse
2
+ from aigear.deploy.gcp.artifacts_image import create_artifacts_image
3
+
4
+
5
+ def get_argument():
6
+ parser = argparse.ArgumentParser(
7
+ description=__doc__,
8
+ formatter_class=argparse.RawDescriptionHelpFormatter)
9
+ parser.add_argument('--dockerfile_path', default=".",
10
+ help='path of dockerfile')
11
+ parser.add_argument('--image_name',
12
+ help='The name of the Docker image')
13
+ parser.add_argument('--image_version', default="latest",
14
+ help='The version of the Docker image')
15
+ args = parser.parse_args()
16
+ return args
17
+
18
+ def artifacts_image_init():
19
+ args = get_argument()
20
+ create_artifacts_image(
21
+ dockerfile_path=args.dockerfile_path,
22
+ image_name=args.image_name,
23
+ image_version = args.image_version
24
+ )
@@ -0,0 +1,6 @@
1
+ from aigear.infrastructure.gcp import Infra
2
+
3
+
4
+ def gcp_infra_init():
5
+ gcp_infra = Infra()
6
+ gcp_infra.create()
@@ -0,0 +1,23 @@
1
+ import os
2
+ import sys
3
+ import argparse
4
+ from aigear.service.grpc.grpc_service import grpc_service
5
+
6
+
7
+ def get_argument():
8
+ # Arg
9
+ parser = argparse.ArgumentParser(
10
+ description=__doc__,
11
+ formatter_class=argparse.RawDescriptionHelpFormatter)
12
+ parser.add_argument('--model_class_path',
13
+ help='Deploy gRPC services by company code')
14
+ args = parser.parse_args()
15
+ return args
16
+
17
+ def grpc_run():
18
+ project_root = os.getcwd()
19
+ if project_root not in sys.path:
20
+ sys.path.insert(0, project_root)
21
+
22
+ args = get_argument()
23
+ grpc_service(args.model_class_path)
@@ -0,0 +1,33 @@
1
+ import argparse
2
+ from ..project import Project
3
+
4
+
5
+ def get_argument():
6
+ parser = argparse.ArgumentParser(
7
+ description=__doc__,
8
+ formatter_class=argparse.RawDescriptionHelpFormatter)
9
+ parser.add_argument(
10
+ "--name",
11
+ default="template_project",
12
+ help="Project name."
13
+ )
14
+ parser.add_argument(
15
+ "--pipeline_versions",
16
+ default="pipeline_version_1",
17
+ type=str,
18
+ help="Comma-separated list of pipeline names (e.g., pipeline_v1,pipeline_v2). If not provided, will use pipeline_version_1"
19
+ )
20
+ args = parser.parse_args()
21
+ return args
22
+
23
+
24
+ def project_init():
25
+ args = get_argument()
26
+ # Parse pipelines
27
+ pipeline_versions = [p.strip() for p in args.pipeline_versions.split(',')]
28
+
29
+ project = Project(
30
+ name=args.name,
31
+ pipeline_versions=pipeline_versions
32
+ )
33
+ project.init()
@@ -0,0 +1,19 @@
1
+ import argparse
2
+ from aigear.deploy.gcp.scheduler import create_scheduler
3
+
4
+
5
+ def get_argument():
6
+ parser = argparse.ArgumentParser(
7
+ description=__doc__,
8
+ formatter_class=argparse.RawDescriptionHelpFormatter)
9
+ parser.add_argument('--version', default="",
10
+ help='Version of the pipeline')
11
+ parser.add_argument('--step_names', default="",
12
+ help='Name of the pipeline step')
13
+ args = parser.parse_args()
14
+ return args
15
+
16
+ def scheduler_init():
17
+ args = get_argument()
18
+ step_names = args.step_names.split(",")
19
+ create_scheduler(args.version, step_names)
@@ -0,0 +1,33 @@
1
+ import importlib
2
+ import logging
3
+ import argparse
4
+ import sys
5
+ import os
6
+
7
+
8
+ def run_step(pipeline_version, step):
9
+ project_root = os.getcwd()
10
+ if project_root not in sys.path:
11
+ sys.path.insert(0, project_root)
12
+
13
+ module_name = f"src.pipelines.{step}"
14
+ try:
15
+ module = importlib.import_module(module_name)
16
+ module.main(pipeline_version)
17
+ except Exception as e:
18
+ logging.error(f"Error while executing {module_name}: {e}")
19
+
20
+ def get_argument():
21
+ parser = argparse.ArgumentParser(
22
+ description=__doc__,
23
+ formatter_class=argparse.RawDescriptionHelpFormatter)
24
+ parser.add_argument('--version', default="",
25
+ help='Version of the pipeline')
26
+ parser.add_argument('--step', default="",
27
+ help='Name of the pipeline step')
28
+ args = parser.parse_args()
29
+ return args
30
+
31
+ def task_run():
32
+ args = get_argument()
33
+ run_step(args.version, args.step)
@@ -0,0 +1,16 @@
1
+ from aigear.common.sh import run_sh, run_sh_stream
2
+ from aigear.common.logger import Logging
3
+ from aigear.common.config import AigearConfig
4
+ from aigear.common.dynamic_type import generate_schema, generate_schema_for_json
5
+ from aigear.common.secretmanager import SecretManager
6
+
7
+
8
+ __all__ = [
9
+ "run_sh",
10
+ "run_sh_stream",
11
+ "Logging",
12
+ "AigearConfig",
13
+ "generate_schema",
14
+ "generate_schema_for_json",
15
+ "SecretManager",
16
+ ]
@@ -0,0 +1,59 @@
1
+ import json
2
+ import os
3
+ from typing import Optional
4
+ from aigear.common.schema.config_schema import Config
5
+ from aigear.common.logger import Logging
6
+
7
+
8
+ logger = Logging(log_name=__name__).console_logging()
9
+
10
+ def read_config(env_path) -> Optional[Config]:
11
+ if not os.path.exists(env_path):
12
+ logger.error(f"Configuration file {env_path} not found.")
13
+ return None
14
+
15
+ with open(env_path, "r", encoding="utf-8") as f:
16
+ cfg = json.load(f)
17
+
18
+ return cfg
19
+
20
+ class AigearConfig:
21
+ _config = None
22
+
23
+ @classmethod
24
+ def load(cls):
25
+ if cls._config:
26
+ return cls._config
27
+
28
+ cfg = read_config(env_path=os.path.join(os.getcwd(), "env.json"))
29
+ cls._config = Config(**cfg["aigear"])
30
+ return cls._config
31
+
32
+ @classmethod
33
+ def get_config(cls) -> Config:
34
+ if not cls._config:
35
+ cls.load()
36
+ return cls._config
37
+
38
+ class PipelinesConfig:
39
+ _config = None
40
+
41
+ @classmethod
42
+ def load(cls):
43
+ if cls._config:
44
+ return cls._config
45
+
46
+ cfg = read_config(env_path=os.path.join(os.getcwd(), "env.json"))
47
+ cls._config = cfg.get("pipelines", {})
48
+ return cls._config
49
+
50
+ @classmethod
51
+ def get_config(cls) -> Config:
52
+ if not cls._config:
53
+ cls.load()
54
+ return cls._config
55
+
56
+ def get_project_name() -> str:
57
+ cfg = read_config(env_path=os.path.join(os.getcwd(), "env.json"))
58
+ project_name = cfg.get("project_name")
59
+ return project_name