-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Removed new-line * Fixed github action * Fixed workflow * Fixed github action * Ignore server mismatch * Ignore server mismatch * Added all requirements * Fixed gh action * More fine grained control over configs * Added defaults * fixed config path * Automate trigger update
- Loading branch information
1 parent
e82b37b
commit 5c40088
Showing
8 changed files
with
225 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Production LLM-COMPLETE | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'llm-complete-guide/**' | ||
concurrency: | ||
# New commit on branch cancels running workflows of the same branch | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
run-staging-workflow: | ||
runs-on: ubuntu-latest | ||
env: | ||
ZENML_HOST: ${{ secrets.ZENML_HOST }} | ||
ZENML_API_KEY: ${{ secrets.ZENML_API_KEY }} | ||
ZENML_PRODUCTION_STACK : 51a49786-b82a-4646-bde7-a460efb0a9c5 | ||
ZENML_GITHUB_SHA: ${{ github.event.pull_request.head.sha }} | ||
ZENML_GITHUB_URL_PR: ${{ github.event.pull_request._links.html.href }} | ||
ZENML_DEBUG: true | ||
ZENML_ANALYTICS_OPT_IN: false | ||
ZENML_LOGGING_VERBOSITY: INFO | ||
ZENML_PROJECT_SECRET_NAME: llm-complete | ||
ZENML_DISABLE_CLIENT_SERVER_MISMATCH_WARNING: True | ||
ZENML_ACTION_ID: 23a4d58c-bd2b-47d5-a41d-0a845d2982f8 | ||
|
||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install requirements | ||
working-directory: ./llm-complete-guide | ||
run: | | ||
pip3 install -r requirements.txt | ||
pip3 install -r requirements-argilla.txt | ||
zenml integration install gcp -y | ||
- name: Connect to ZenML server | ||
working-directory: ./llm-complete-guide | ||
run: | | ||
zenml init | ||
zenml connect --url $ZENML_HOST --api-key $ZENML_API_KEY | ||
- name: Set stack (Production) | ||
working-directory: ./llm-complete-guide | ||
run: | | ||
zenml stack set ${{ env.ZENML_PRODUCTION_STACK }} | ||
- name: Run pipeline, create pipeline, configure trigger (Production) | ||
working-directory: ./llm-complete-guide | ||
run: | | ||
python scripts/gh_action_rag.py --no-cache --create-template --action-id ${{ env.ZENML_ACTION_ID }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# Apache Software License 2.0 | ||
# | ||
# Copyright (c) ZenML GmbH 2024. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
from datetime import datetime | ||
from pathlib import Path | ||
from typing import Optional | ||
from uuid import UUID | ||
|
||
import click | ||
from zenml.client import Client | ||
|
||
from pipelines import llm_basic_rag | ||
|
||
|
||
@click.command( | ||
help=""" | ||
ZenML LLM Complete - Rag Pipeline | ||
""" | ||
) | ||
@click.option( | ||
"--no-cache", | ||
"no_cache", | ||
is_flag=True, | ||
default=False, | ||
help="Disable cache.", | ||
) | ||
|
||
@click.option( | ||
"--create-template", | ||
"create_template", | ||
is_flag=True, | ||
default=False, | ||
help="Create a run template.", | ||
) | ||
@click.option( | ||
"--config", | ||
"config", | ||
default="rag_local_dev.yaml", | ||
help="Specify a configuration file" | ||
) | ||
@click.option( | ||
"--action-id", | ||
"action_id", | ||
default=None, | ||
help="Specify an action ID" | ||
) | ||
def main( | ||
no_cache: bool = False, | ||
config: Optional[str]= "rag_local_dev.yaml", | ||
create_template: bool = False, | ||
action_id: Optional[str] = None | ||
): | ||
""" | ||
Executes the pipeline to train a basic RAG model. | ||
Args: | ||
no_cache (bool): If `True`, cache will be disabled. | ||
config (str): The path to the configuration file. | ||
create_template (bool): If `True`, a run template will be created. | ||
action_id (str): The action ID. | ||
""" | ||
client = Client() | ||
config_path = Path(__file__).parent.parent / "configs" / config | ||
|
||
if create_template: | ||
# run pipeline | ||
run = llm_basic_rag.with_options( | ||
config_path=str(config_path), | ||
enable_cache=not no_cache | ||
)() | ||
# create new run template | ||
rt = client.create_run_template( | ||
name=f"production-llm-complete-{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}", | ||
deployment_id=run.deployment_id | ||
) | ||
# update the action with the new template | ||
client.update_action( | ||
name_id_or_prefix=UUID(action_id), | ||
configuration={ | ||
"template_id": str(rt.id) | ||
} | ||
) | ||
|
||
else: | ||
llm_basic_rag.with_options( | ||
config_path=str(config_path), | ||
enable_cache=not no_cache | ||
)() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |