Skip to content

Commit

Permalink
Update build image (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
yonishelach authored Feb 3, 2025
1 parent 09cb41e commit 4466b01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 38 deletions.
41 changes: 7 additions & 34 deletions notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
"source": [
"### 1.3 Fill the tokens and URL\n",
"\n",
"> **⚠️ Important** Please fill the following variables in your `.env` file.\n",
"\n",
"Three tokens are required to run the demo end-to-end:\n",
"* [OpenAI ChatGPT](https://chat.openai.com/) — To generate conversations, two tokens are required:\n",
" * `OPENAI_API_KEY`\n",
Expand All @@ -103,6 +105,7 @@
"> Note: The requirement for the OpenAI token will be removed soon in favor of an open-source LLM.\n",
"\n",
"* [MySQL](https://www.mysql.com/) — A URL with username and password for collecting the calls into the DB.\n",
" * `MYSQL_URL`\n",
"> If you wish to install mysql using helm chart you can use the command below - \n",
"> * `helm install -n <\"namesapce\"> myrelease bitnami/mysql --set auth.rootPassword=sql123 --set auth.database=mlrun_demos --set primary.service.ports.mysql=3111 --set primary.persistence.enabled=false`\n",
"> * Example for MYSQL_URL if you use the above command - `mysql+pymysql://root:sql123@myrelease-mysql.<\"namesapce\">.svc.cluster.local:3111/mlrun_demos`\n",
Expand All @@ -118,45 +121,14 @@
},
"outputs": [],
"source": [
"import dotenv\n",
"import os\n",
"import sys\n",
"import mlrun\n",
" \n",
"sys.path.insert(0, os.path.abspath(\"./\"))\n",
"\n",
"sys.path.insert(0, os.path.abspath(\"./\"))\n",
"\n",
"from src.common import ProjectSecrets"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "ebdc8789-5d27-4c26-acc3-f7880ae36095",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# OpenAI tokens:\n",
"OPENAI_API_BASE = ...\n",
"OPENAI_API_KEY = ...\n",
"\n",
"# MySQL URL:\n",
"MYSQL_URL = ..."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "4c54ed9e-3f91-4ca4-a970-16797df94f6f",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"os.environ[ProjectSecrets.OPENAI_API_KEY] = OPENAI_API_KEY\n",
"os.environ[ProjectSecrets.OPENAI_API_BASE] = OPENAI_API_BASE\n",
"os.environ[ProjectSecrets.MYSQL_URL] = MYSQL_URL"
"dotenv.load_dotenv()"
]
},
{
Expand All @@ -173,6 +145,7 @@
"* `source : str` &mdash; The git repo source of the project to clone when each function is running.\n",
"* `default_image : str` &mdash; The default image to use for running the workflow's functions. For the sake of simplicity, the demo uses the same image for all the functions.\n",
"* `gpus: int` &mdash; The number of GPUs to use when running the demo. 0 means CPU.\n",
"* `node_selector: Dict[str, str]` &mdash; The node selector to use when running the demo (optional).\n",
"* `node_name: str` &mdash; The node name to run the demo on (optional).\n",
"\n",
"> Note: Multiple GPUs (`gpus` > 1) automatically deploy [OpenMPI](https://www.open-mpi.org/) jobs for **better performance and GPU utilization**.\n",
Expand Down
8 changes: 4 additions & 4 deletions project_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def setup(
build_image = project.get_param(key="build_image", default=False)
gpus = project.get_param(key="gpus", default=0)
node_name = project.get_param(key="node_name", default=None)
node_selector = project.get_param(key="node_selector", default={"alpha.eksctl.io/nodegroup-name": "added-t4"})
node_selector = project.get_param(key="node_selector", default=None)

# Set the project git source:
if source:
Expand Down Expand Up @@ -108,8 +108,7 @@ def _build_image(project: mlrun.projects.MlrunProject, with_gpu: bool):
] if with_gpu else []

other_requirements = [
"pip install langchain==0.3.13 openai==1.58.1 langchain_community==0.3.13 pydub==0.25.1",
"pip install streamlit==1.28.0 st-annotated-text==4.0.1 spacy==3.7.2 librosa==0.10.1 presidio-anonymizer==2.2.34 presidio-analyzer==2.2.34 nltk==3.8.1 flair==0.13.0",
"pip install mlrun langchain==0.2.17 openai==1.58.1 langchain_community==0.2.19 pydub==0.25.1 streamlit==1.28.0 st-annotated-text==4.0.1 spacy==3.7.2 librosa==0.10.1 presidio-anonymizer==2.2.34 presidio-analyzer==2.2.34 nltk==3.8.1 flair==0.13.0 htbuilder==0.6.2",
"python -m spacy download en_core_web_lg",
"pip install -U SQLAlchemy",
"pip uninstall -y onnxruntime-gpu onnxruntime",
Expand Down Expand Up @@ -168,7 +167,8 @@ def _set_function(

# Configure GPUs according to the given kind:
if gpus >= 1:
mlrun_function.with_node_selection(node_selector=node_selector)
if node_selector:
mlrun_function.with_node_selection(node_selector=node_selector)
if kind == "mpijob":
# 1 GPU for each rank:
mlrun_function.with_limits(gpus=1)
Expand Down

0 comments on commit 4466b01

Please sign in to comment.