├── .DS_Store
├── LICENSE
├── README.md
├── __pycache__
└── paradigm.cpython-310.pyc
├── argo-darwin-amd64
├── examples
└── basic
│ ├── p1.py
│ ├── p2.ipynb
│ ├── p3.py
│ └── requirements.p3
├── install-aws.sh
├── install.sh
├── paradigm.egg-info
├── PKG-INFO
├── SOURCES.txt
├── dependency_links.txt
├── entry_points.txt
├── requires.txt
└── top_level.txt
├── paradigm.py
├── paradigm_aws.py
├── rbac.yaml
├── requirements.txt
├── setup-aws.py
├── setup.py
└── utils
├── .DS_Store
└── images
├── .DS_Store
├── logo_slogan_2.png
├── prdm-demo-1.gif
├── prdm-demo-2.gif
└── tutorial_thumbnail.png
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ParadigmAI/paradigm/c89047c1ec85c9726f959d00e45366d79c9a100c/.DS_Store
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 🌟 **With Paradigm, you ML code is production-ready from the beginning**
13 |
14 | Paradigm is a light-weight, lightning-fast, supremely adaptable tool, effortlessly packaging your ML code into robust pipelines for seamless deployment on Kubernetes. Bypass the need for code refactoring as Paradigm intelligently interprets your Python notebooks and scripts, priming them for scalable production. Paradigm is your ultimate ally in ML deployment, merging unparalleled speed, adaptability, and simplicity into one package.
15 |
16 | Official website - [paradigmai.net](https://www.paradigmai.net)
17 |
18 | # Paradigm in Action
19 | ## Terminal View
20 | 
21 |
22 | ## DAG View
23 | 
24 |
25 | # Deploy an ML pipeline in just 2 steps
26 |
27 | ```console
28 | $ paradigm launch --step
29 | $ paradigm deploy
30 | ```
31 |
32 | # Quickstart
33 |
34 | ## Video
35 | [](https://youtu.be/mihz5iaJ3FY)
36 |
37 |
38 |
39 | ## Try Locally 💻
40 |
41 | You need a Kubernetes cluster and `kubectl` set up to be able to access that cluster. For this to run locally, we recommend using `minikube`.
42 | - Please refer to the [minikube documentation](https://minikube.sigs.k8s.io/docs/)
43 |
44 | ### Set up Paradigm
45 |
46 | - (Recommended) Create a new Python environment with your preferred environment manager
47 | - Clone this repo
48 | - `git clone https://github.com/ParadigmAI/paradigm.git`
49 | - Go into the directory
50 | - `cd paradigm`
51 | - Make the installation script executable
52 | - `chmod +x install.sh`
53 | - Run the intallation script
54 | - `./install.sh`
55 | - Validate if paradigm was properly installed
56 | - `paradigm --help`
57 |
58 | ### Now let's move into your ML project folder
59 |
60 | Your folder can contain one or more scripts or Python notebooks that you want to execute as steps in an ML pipeline.
61 |
62 | - First, let's configure your current terminal session to use the Docker daemon inside the Minikube environment instead of the default Docker daemon on your host machine. This eliminated the need for an image registry when working locally.
63 | - `eval $(minikube docker-env)`
64 |
65 | **From here we follow a basic example project just to make it easier to exaplin the commands. Please change the necessary parameters according to your project**
66 | - The preferred directory structure should be as follows. In the below example, `p1, p2 and p3` represent the names of the python scripts or notebooks you have. (Refer the [examples/basic](./examples/basic))
67 | - IMPORTANT - Note the `requirements.` files. You have to create a txt with that specific naming **only for the scripts or notebooks that have additional dependencies**. It becomes the `requirements.txt` for that step. We promise this is the only file addition before taking your ML code to prodution.
68 | - Example:
69 | ```
70 | - 📁 project_root
71 | - 📄 p1.py
72 | - 📄 p2.ipynb
73 | - 📄 p3.py
74 | - 📄 requirements.p1
75 | - 📄 requirements.p3
76 | ```
77 |
78 | - Now we are ready to let Paradigm get things ready before deploying to Kubernetes. Include the scripts/notebook you want as steps in the below command. This command basically containerizes your code.
79 | ```
80 | paradigm launch --steps p1 p2 p3
81 | ```
82 | - As the final step, deploy the pipeline with the below command.
83 |
84 | ```
85 | paradigm deploy --steps p1 p2 --dependencies "p2:p1,p3:p2|p1" --deployment p3 --deployment_port 8000 --output workflow.yaml --name pipeline1
86 | ```
87 | - In the above command:
88 | - `--steps` should speicify all steps, except any step that should be run as a service, e.g., an API endpoint.
89 | - `--dependencies "p2:p1,p3:p2|p1"` defines the graph stucture (DAG) on how the steps should be run. In this example, we are stating that step `p2` is dependent on `p1` and step `p3` is dependent on both `p2` and `p1`.
90 | - `--deployment p3` defines a service that needs to be run at the end of the pipeline. Hence, we don't mention is under `--steps`.
91 | - `--deployment_port` is defined if the above service is exposed via a specific port internally.
92 | - `--name` can be any name that you want to give this particualr pipeline
93 |
94 | - (OPTIONAL) You can use Argo UI to observe all pipelines and get logs. For that, first make it accessible via your browser by running the below command.
95 | - `kubectl -n paradigm port-forward deployment/argo-server 2746:2746`
96 | - Now in your local browser, go to `http://localhost:2746`
97 |
98 | - (OPTIONAL) To access the service that is deployed in the previous set (for example an API endpoint), run the following code since we're working inside minikube.
99 |
100 | - `minikube service deploy-p3 -n paradigm`
101 |
102 | - (OPTIONAL) In case you want to delete the running service and deployment, use the following commands. `` is the name of the file that has the deolyment code.
103 | - `kubectl delete deployment deploy- -n paradigm`
104 | - `kubectl delete service deploy- -n paradigm`
105 |
106 |
107 |
108 | ## To Deploy in AWS ☁️
109 |
110 | You need a Kubernetes cluster and `kubectl` set up to be able to access that cluster. On AWS, we use Amazon Elastic Kubernetes Service (Amazon EKS) for this.
111 | - Please refer to the [Amazon EKS](https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html) on how to set things up
112 | - Make sure you can [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) installed and configured as well
113 |
114 | Also, make sure [Docker](https://docs.docker.com/engine/install/) is installed and running in your environment
115 |
116 | ### Set up Paradigm
117 |
118 | In a terminal with the above kubectl access, follow the below steps.
119 |
120 | - (Recommended) Create a new Python environment with your preferred environment manager
121 | - Clone this repo
122 | - `git clone https://github.com/ParadigmAI/paradigm.git`
123 | - Go into the directory
124 | - `cd paradigm`
125 | - Make the installation script executable
126 | - `chmod +x install-aws.sh`
127 | - Run the intallation script
128 | - `./install-aws.sh`
129 | - Validate if paradigm was properly installed
130 | - `paradigm --help`
131 |
132 | ### Now let's move into your ML project folder
133 |
134 | Your folder can contain one or more scripts/notebooks that you want to execute as steps in an ML pipeline.
135 |
136 | **From here we follow a basic example project just to make it easier to exaplin the commands. Please change the necessary parameters according to your project**
137 | - The preferred directory structure should be as follows. In the below example, `p1, p2 and p3` represent the names of the python scripts or notebooks you have. (Refer the [examples/basic](./examples/basic))
138 | - IMPORTANT - Note the `requirements.` files. You have to create a txt with that specific naming **only for the scripts or notebooks that have additional dependencies**. It becomes the `requirements.txt` for that step. We promise this is the only file addition before taking your ML code to prodution.
139 | - Example:
140 | ```
141 | - 📁 project_root
142 | - 📄 p1.py
143 | - 📄 p2.ipynb
144 | - 📄 p3.py
145 | - 📄 requirements.p1
146 | - 📄 requirements.p3
147 | ```
148 |
149 | - Now we are ready to let Paradigm get things ready before deploying to Kubernetes. Include the scripts/notebook you want as steps in the below command. This command basically containerizes your code.
150 | ```
151 | paradigm launch --steps p1 p2 p3 --region_name us-east-1
152 | ```
153 | - As the final step, deploy the pipeline with the below command.
154 |
155 | ```
156 | paradigm deploy --steps p1 p2 --dependencies "p2:p1,p3:p2|p1" --deployment p3 --deployment_port 8000 --output workflow.yaml --name pipe1 --region_name us-east-1
157 | ```
158 | - In the above command:
159 | - `--steps` should speicify all steps, except any step that should be run as a service, e.g., an API endpoint.
160 | - `--dependencies "p2:p1,p3:p2|p1"` defines the graph stucture (DAG) on how the steps should be run. In this example, we are stating that step `p2` is dependent on `p1` and step `p3` is dependent on both `p2` and `p1`.
161 | - `--deployment p3` defines a service that needs to be run at the end of the pipeline. Hence, we don't mention is under `--steps`.
162 | - `--deployment_port` is defined if the above service is exposed via a specific port internally.
163 | - `--name` can be any name that you want to give this particualr pipeline
164 | - `--region_name` is the aws region that you want to use
165 |
166 | - (OPTIONAL) You can use Argo UI to observe all pipelines and get logs. For that, first make it accessible via your browser by running the below command.
167 | - `kubectl -n paradigm port-forward deployment/argo-server 2746:2746`
168 | - Now I your local browser, go to `http://localhost:2746`
169 |
170 | - (OPTIONAL) In case you want to delete the running service and deployment, use the following commands. `` is the make of the file that has the deolyment code.
171 | - `kubectl delete deployment deploy- -n paradigm`
172 | - `kubectl delete service deploy- -n paradigm`
173 |
174 |
175 |
176 |
177 |
178 |
179 | ## Learn more
180 |
181 | | Section | Description |
182 | |-|-|
183 | | [Documentation](https://paradigmai.github.io/paradigm-docs/) | Full documentation and tutorials |
184 | | [Basic Tutorial](https://paradigmai.github.io/paradigm-docs/Tutorials/basic_example/) | The simplest example with Paradigm |
185 |
186 |
187 | ## Contributing
188 |
189 | Suggestions on additional features and functionality are highly appreciated. General instructions on how to contribute are mentioned in [CONTRIBUTING](CONTRIBUTING.md)
190 |
191 | ## Getting help
192 |
193 | Please use the issues tracker of this repository to report on any bugs or questions you have.
194 |
195 | Also you can join the [DISCORD](https://discord.gg/KxHPMsBdyp)
--------------------------------------------------------------------------------
/__pycache__/paradigm.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ParadigmAI/paradigm/c89047c1ec85c9726f959d00e45366d79c9a100c/__pycache__/paradigm.cpython-310.pyc
--------------------------------------------------------------------------------
/argo-darwin-amd64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ParadigmAI/paradigm/c89047c1ec85c9726f959d00e45366d79c9a100c/argo-darwin-amd64
--------------------------------------------------------------------------------
/examples/basic/p1.py:
--------------------------------------------------------------------------------
1 | print('p1 woot')
--------------------------------------------------------------------------------
/examples/basic/p2.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": null,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "print(\"notebook woot\")"
10 | ]
11 | },
12 | {
13 | "cell_type": "code",
14 | "execution_count": null,
15 | "metadata": {},
16 | "outputs": [],
17 | "source": [
18 | "print(\"notebook second cell\")"
19 | ]
20 | }
21 | ],
22 | "metadata": {
23 | "kernelspec": {
24 | "display_name": "Python 3",
25 | "language": "python",
26 | "name": "python3"
27 | },
28 | "language_info": {
29 | "name": "python",
30 | "version": "3.9.16"
31 | },
32 | "orig_nbformat": 4,
33 | "vscode": {
34 | "interpreter": {
35 | "hash": "a665b5d41d17b532ea9890333293a1b812fa0b73c9c25c950b3cedf1bebd0438"
36 | }
37 | }
38 | },
39 | "nbformat": 4,
40 | "nbformat_minor": 2
41 | }
42 |
--------------------------------------------------------------------------------
/examples/basic/p3.py:
--------------------------------------------------------------------------------
1 | from fastapi import FastAPI
2 | import uvicorn
3 |
4 | app = FastAPI()
5 |
6 | @app.get("/")
7 | def hello_world():
8 | return {"message": "Hello, World!"}
9 |
10 | if __name__ == "__main__":
11 | uvicorn.run(app, host="0.0.0.0", port=8000)
12 |
13 |
--------------------------------------------------------------------------------
/examples/basic/requirements.p3:
--------------------------------------------------------------------------------
1 | fastapi
2 | uvicorn
--------------------------------------------------------------------------------
/install-aws.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Install Argo Workflows CLI
4 | echo "Installing..."
5 | mv setup-aws.py setup.py
6 | kubectl create namespace paradigm
7 | kubectl create namespace argo
8 | kubectl apply -f rbac.yaml
9 | kubectl apply -n argo -f https://github.com/argoproj/argo-workflows/releases/download/v3.4.7/install.yaml
10 | kubectl patch deployment \
11 | argo-server \
12 | --namespace argo \
13 | --type='json' \
14 | -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/args", "value": [
15 | "server",
16 | "--auth-mode=server"
17 | ]}]'
18 | # kubectl -n paradigm port-forward deployment/argo-server 2746:2746
19 |
20 | # Detect the running operating system
21 | os_name="$(uname)"
22 |
23 | # Execute commands according to the detected OS
24 | case "${os_name}" in
25 | Darwin) # MacOS
26 | echo "Detected MacOS"
27 | # Download the binary
28 | curl -sLO https://github.com/argoproj/argo-workflows/releases/download/v3.4.7/argo-darwin-amd64.gz
29 |
30 | # Unzip
31 | gunzip argo-darwin-amd64.gz
32 |
33 | # Make binary executable
34 | chmod +x argo-darwin-amd64
35 |
36 | # Move binary to path
37 | mv ./argo-darwin-amd64 /usr/local/bin/argo
38 | ;;
39 | Linux)
40 | echo "Detected Linux"
41 | # Download the binary
42 | curl -sLO https://github.com/argoproj/argo-workflows/releases/download/v3.4.7/argo-linux-amd64.gz
43 |
44 | # Unzip
45 | gunzip argo-linux-amd64.gz
46 |
47 | # Make binary executable
48 | chmod +x argo-linux-amd64
49 |
50 | # Move binary to path
51 | sudo mv ./argo-linux-amd64 /usr/local/bin/argo
52 | ;;
53 | *)
54 | echo "Unsupported operating system: ${os_name}"
55 | exit 1
56 | ;;
57 | esac
58 |
59 | #Installing Paradigm Utility
60 |
61 | # Install requirements
62 | pip install -r requirements.txt
63 |
64 | # Install command-line utility
65 | pip install -e .
66 |
67 | echo "Installation complete! You can now use the 'paradigm' commands."
68 |
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Install Argo Workflows CLI
4 | echo "Installing..."
5 | mv setup-local.py setup.py
6 | kubectl create namespace paradigm
7 | kubectl create namespace argo
8 | kubectl apply -f rbac.yaml
9 | kubectl apply -n argo -f https://github.com/argoproj/argo-workflows/releases/download/v3.4.7/install.yaml
10 | kubectl patch deployment \
11 | argo-server \
12 | --namespace argo \
13 | --type='json' \
14 | -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/args", "value": [
15 | "server",
16 | "--auth-mode=server"
17 | ]}]'
18 | # kubectl -n paradigm port-forward deployment/argo-server 2746:2746
19 |
20 | # Detect the running operating system
21 | os_name="$(uname)"
22 |
23 | # Execute commands according to the detected OS
24 | case "${os_name}" in
25 | Darwin) # MacOS
26 | echo "Detected MacOS"
27 | # Download the binary
28 | curl -sLO https://github.com/argoproj/argo-workflows/releases/download/v3.4.7/argo-darwin-amd64.gz
29 |
30 | # Unzip
31 | gunzip argo-darwin-amd64.gz
32 |
33 | # Make binary executable
34 | chmod +x argo-darwin-amd64
35 |
36 | # Move binary to path
37 | mv ./argo-darwin-amd64 /usr/local/bin/argo
38 | ;;
39 | Linux)
40 | echo "Detected Linux"
41 | # Download the binary
42 | curl -sLO https://github.com/argoproj/argo-workflows/releases/download/v3.4.7/argo-linux-amd64.gz
43 |
44 | # Unzip
45 | gunzip argo-linux-amd64.gz
46 |
47 | # Make binary executable
48 | chmod +x argo-linux-amd64
49 |
50 | # Move binary to path
51 | sudo mv ./argo-linux-amd64 /usr/local/bin/argo
52 | ;;
53 | *)
54 | echo "Unsupported operating system: ${os_name}"
55 | exit 1
56 | ;;
57 | esac
58 |
59 | #Installing Paradigm Utility
60 |
61 | # Install requirements
62 | pip install -r requirements.txt
63 |
64 | # Install command-line utility
65 | pip install -e .
66 |
67 | echo "Installation complete! You can now use the 'paradigm' commands."
68 |
--------------------------------------------------------------------------------
/paradigm.egg-info/PKG-INFO:
--------------------------------------------------------------------------------
1 | Metadata-Version: 2.1
2 | Name: paradigm
3 | Version: 0.1.0
4 | License-File: LICENSE
5 |
--------------------------------------------------------------------------------
/paradigm.egg-info/SOURCES.txt:
--------------------------------------------------------------------------------
1 | LICENSE
2 | README.md
3 | setup.py
4 | paradigm.egg-info/PKG-INFO
5 | paradigm.egg-info/SOURCES.txt
6 | paradigm.egg-info/dependency_links.txt
7 | paradigm.egg-info/entry_points.txt
8 | paradigm.egg-info/requires.txt
9 | paradigm.egg-info/top_level.txt
--------------------------------------------------------------------------------
/paradigm.egg-info/dependency_links.txt:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/paradigm.egg-info/entry_points.txt:
--------------------------------------------------------------------------------
1 | [console_scripts]
2 | paradigm = paradigm:main
3 |
--------------------------------------------------------------------------------
/paradigm.egg-info/requires.txt:
--------------------------------------------------------------------------------
1 | PyYAML
2 | docker
3 |
--------------------------------------------------------------------------------
/paradigm.egg-info/top_level.txt:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/paradigm.py:
--------------------------------------------------------------------------------
1 | import argparse
2 | import yaml
3 | import docker
4 | import os
5 | import shutil
6 | import sys
7 | import subprocess
8 | import json
9 | from halo import Halo
10 |
11 |
12 | spinner = Halo(text='⚡ Processing...', spinner='dots12')
13 |
14 | def convert_ipynb_to_py(input_file, step):
15 | output_file = f"./{step}/" + os.path.splitext(input_file)[0] + ".py"
16 | with open(input_file, "r", encoding="utf-8") as file:
17 | notebook = json.load(file)
18 |
19 | with open(output_file, "w", encoding="utf-8") as output:
20 | for cell in notebook["cells"]:
21 | if cell["cell_type"] == "code":
22 | code = "".join(cell["source"])
23 | output.write(code)
24 | output.write("\n\n")
25 |
26 | def build_and_push_docker_image(step):
27 | client = docker.from_env()
28 | image_tag = f"{step}:latest"
29 |
30 | # Create step directory if not exists
31 | step_dir = f"./{step}"
32 | if not os.path.exists(step_dir):
33 | os.mkdir(step_dir)
34 |
35 | # Copy Python file and requirements.txt to step directory
36 | # also convert any notebook to a python script
37 | if os.path.exists(f"{step}.ipynb"):
38 | convert_ipynb_to_py(f"{step}.ipynb", step)
39 | else:
40 | shutil.copy(f"{step}.py", step_dir)
41 |
42 | # if no requirements for a file, create an empty requirements file
43 | if os.path.exists(f"requirements.{step}"):
44 | shutil.copy(f"requirements.{step}", step_dir)
45 | else:
46 | with open(f"{step_dir}/" + f"requirements.{step}", "w") as file:
47 | file.write("")
48 |
49 | # Rename requirements.txt in step directory
50 | os.rename(f"{step_dir}/requirements.{step}", f"{step_dir}/requirements.txt")
51 |
52 | # Generate Dockerfile
53 | dockerfile_content = f"""\
54 | FROM python:3.9
55 |
56 | WORKDIR /app
57 |
58 | COPY ./{step}.py /app
59 | COPY ./requirements.txt /app
60 |
61 | RUN pip3 install --no-cache-dir -r requirements.txt
62 |
63 | CMD ["python", "./{step}.py"]
64 | """
65 |
66 | dockerfile_path = f"{step_dir}/Dockerfile"
67 | with open(dockerfile_path, "w") as dockerfile:
68 | dockerfile.write(dockerfile_content)
69 |
70 | print(f"Building Docker image: {image_tag}")
71 | image, _ = client.images.build(path=step_dir, tag=image_tag)
72 |
73 | def containerize_steps(steps):
74 | for step in steps:
75 | if not os.path.exists(step):
76 | os.mkdir(step)
77 | build_and_push_docker_image(step)
78 |
79 | def create_workflow_yaml(steps=None, dependencies=None, deployment_step=None, deployment_port=None, name=None):
80 | dag_tasks = []
81 | container_templates = []
82 |
83 | if steps:
84 | for step in steps:
85 | task_name = f"step-{step}"
86 | dag_task = {
87 | "name": task_name,
88 | "template": step
89 | }
90 |
91 | if step in dependencies:
92 | dag_task["dependencies"] = [f"step-{d}" for d in dependencies[step]]
93 |
94 | dag_tasks.append(dag_task)
95 |
96 | container_templates.append({
97 | "name": step,
98 | "container": {
99 | "image": f"{step}:latest",
100 | "command": ["python", f"{step}.py"],
101 | "imagePullPolicy": "Always"
102 | }
103 | })
104 |
105 | templates = [
106 | {
107 | "name": "dag-steps",
108 | "dag": {
109 | "tasks": dag_tasks
110 | }
111 | },
112 | *container_templates
113 | ]
114 |
115 | if deployment_step:
116 |
117 | if deployment_step in dependencies:
118 | deploy_task = {
119 | "name": f"step-{deployment_step}",
120 | "dependencies": [f"step-{d}" for d in dependencies[deployment_step]],
121 | "template": f"deploy-{deployment_step}"
122 | }
123 | else:
124 | deploy_task = {
125 | "name": f"step-{deployment_step}",
126 | "template": f"deploy-{deployment_step}"
127 | }
128 | dag_tasks.append(deploy_task)
129 |
130 | deployment_template = {
131 | "name": f"deploy-{deployment_step}",
132 | "script": {
133 | "image": "bitnami/kubectl:latest",
134 | "command": ["/bin/bash"],
135 | "source": f"""kubectl apply -f - <