Skip to content

Commit f610a31

Browse files
authored
Small adjustments for migration to different tenant (#142)
* Small adjustments for migration to different tenant * Fixed secret reference * Fixed secret reference * Staging github action needs aws requirements
1 parent 5a01673 commit f610a31

File tree

6 files changed

+71
-24
lines changed

6 files changed

+71
-24
lines changed

.github/workflows/production_run_complete_llm.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ jobs:
1414
run-staging-workflow:
1515
runs-on: ubuntu-latest
1616
env:
17-
ZENML_HOST: ${{ secrets.ZENML_HOST }}
18-
ZENML_API_KEY: ${{ secrets.ZENML_API_KEY }}
19-
ZENML_PRODUCTION_STACK : 51a49786-b82a-4646-bde7-a460efb0a9c5
17+
ZENML_HOST: ${{ secrets.ZENML_PROJECTS_HOST }}
18+
ZENML_API_KEY: ${{ secrets.ZENML_PROJECTS_API_KEY }}
19+
ZENML_PRODUCTION_STACK: b3951d43-0fb2-4d32-89c5-3399374e7c7e # Set this to your production stack ID
2020
ZENML_GITHUB_SHA: ${{ github.event.pull_request.head.sha }}
2121
ZENML_GITHUB_URL_PR: ${{ github.event.pull_request._links.html.href }}
2222
ZENML_DEBUG: true
2323
ZENML_ANALYTICS_OPT_IN: false
2424
ZENML_LOGGING_VERBOSITY: INFO
2525
ZENML_PROJECT_SECRET_NAME: llm-complete
2626
ZENML_DISABLE_CLIENT_SERVER_MISMATCH_WARNING: True
27-
ZENML_ACTION_ID: 23a4d58c-bd2b-47d5-a41d-0a845d2982f8
27+
ZENML_EVENT_SOURCE_ID: ae6ae536-d811-4838-a44b-744b768a0f31 # Set this to your preferred event source ID
28+
ZENML_SERVICE_ACCOUNT_ID: fef76af2-382f-4ab2-9e6b-5eb85a303f0e # Set this to your service account ID or delete
2829

2930
steps:
3031
- name: Check out repository code
@@ -55,4 +56,4 @@ jobs:
5556
- name: Run pipeline, create pipeline, configure trigger (Production)
5657
working-directory: ./llm-complete-guide
5758
run: |
58-
python gh_action_rag.py --no-cache --create-template --action-id ${{ env.ZENML_ACTION_ID }} --config rag_gcp.yaml
59+
python gh_action_rag.py --no-cache --create-template ----event-source-id --service-account-id ${{ env.ZENML_SERVICE_ACCOUNT_ID }} --action-id ${{ env.ZENML_ACTION_ID }} --config rag_gcp.yaml

.github/workflows/staging_run_complete_llm.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
run-staging-workflow:
1313
runs-on: ubuntu-latest
1414
env:
15-
ZENML_HOST: ${{ secrets.ZENML_HOST }}
16-
ZENML_API_KEY: ${{ secrets.ZENML_API_KEY }}
17-
ZENML_STAGING_STACK: 51a49786-b82a-4646-bde7-a460efb0a9c5
15+
ZENML_HOST: ${{ secrets.ZENML_PROJECTS_HOST }}
16+
ZENML_API_KEY: ${{ secrets.ZENML_PROJECTS_API_KEY }}
17+
ZENML_STAGING_STACK : 67166d73-a44e-42f9-b67f-011e9afab9b5 # Set this to your staging stack ID
1818
ZENML_GITHUB_SHA: ${{ github.event.pull_request.head.sha }}
1919
ZENML_GITHUB_URL_PR: ${{ github.event.pull_request._links.html.href }}
2020
ZENML_DEBUG: true
@@ -36,7 +36,7 @@ jobs:
3636
run: |
3737
pip3 install -r requirements.txt
3838
pip3 install -r requirements-argilla.txt
39-
zenml integration install gcp -y
39+
zenml integration install aws s3 -y
4040
4141
- name: Connect to ZenML server
4242
working-directory: ./llm-complete-guide

llm-complete-guide/configs/embeddings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ settings:
1616
- pandas
1717
- numpy
1818
- sentence-transformers>=3
19-
- transformers[torch]
19+
- transformers[torch]==4.43.1
2020
- litellm
2121
- ollama
2222
- tiktoken

llm-complete-guide/configs/synthetic.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ settings:
1313
- pandas
1414
- numpy
1515
- sentence-transformers>=3
16-
- transformers
16+
- transformers==4.43.1
1717
- litellm
1818
- ollama
1919
- tiktoken

llm-complete-guide/gh_action_rag.py

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import click
2323
import yaml
2424
from zenml.client import Client
25+
from zenml.exceptions import ZenKeyError
2526

2627
from pipelines.llm_basic_rag import llm_basic_rag
2728

@@ -53,16 +54,23 @@
5354
help="Specify a configuration file"
5455
)
5556
@click.option(
56-
"--action-id",
57-
"action_id",
57+
"--service-account-id",
58+
"service_account_id",
5859
default=None,
59-
help="Specify an action ID"
60+
help="Specify a service account ID"
61+
)
62+
@click.option(
63+
"--event-source-id",
64+
"event_source_id",
65+
default=None,
66+
help="Specify an event source ID"
6067
)
6168
def main(
6269
no_cache: bool = False,
6370
config: Optional[str]= "rag_local_dev.yaml",
6471
create_template: bool = False,
65-
action_id: Optional[str] = None
72+
service_account_id: Optional[str] = None,
73+
event_source_id: Optional[str] = None
6674
):
6775
"""
6876
Executes the pipeline to train a basic RAG model.
@@ -72,6 +80,8 @@ def main(
7280
config (str): The path to the configuration file.
7381
create_template (bool): If `True`, a run template will be created.
7482
action_id (str): The action ID.
83+
service_account_id (str): The service account ID.
84+
event_source_id (str): The event source ID.
7585
"""
7686
client = Client()
7787
config_path = Path(__file__).parent / "configs" / config
@@ -80,6 +90,7 @@ def main(
8090
config = yaml.safe_load(file)
8191

8292
if create_template:
93+
8394
# run pipeline
8495
run = llm_basic_rag.with_options(
8596
config_path=str(config_path),
@@ -90,14 +101,49 @@ def main(
90101
name=f"production-llm-complete-{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}",
91102
deployment_id=run.deployment_id
92103
)
93-
# update the action with the new template
94-
client.update_action(
95-
name_id_or_prefix=UUID(action_id),
96-
configuration={
97-
"template_id": str(rt.id),
98-
"run_config": pop_restricted_configs(config)
99-
}
100-
)
104+
105+
try:
106+
# Check if an action ahs already be configured for this pipeline
107+
action = client.get_action(
108+
name_id_or_prefix="LLM Complete (production)",
109+
allow_name_prefix_match=True
110+
)
111+
except ZenKeyError:
112+
if not event_source_id:
113+
raise RuntimeError("An event source is required for this workflow.")
114+
115+
if not service_account_id:
116+
service_account_id = client.create_service_account(
117+
name="github-action-sa",
118+
description="To allow triggered pipelines to run with M2M authentication."
119+
).id
120+
121+
action_id = client.create_action(
122+
name="LLM Complete (production)",
123+
configuration={
124+
"template_id": str(rt.id),
125+
"run_config": pop_restricted_configs(config)
126+
},
127+
service_account_id=service_account_id,
128+
auth_window=0,
129+
).id
130+
client.create_trigger(
131+
name="Production Trigger LLM-Complete",
132+
event_source_id=UUID(event_source_id),
133+
event_filter={"event_type": "tag_event"},
134+
action_id=action_id,
135+
description="Trigger pipeline to reindex everytime the docs are updated through git."
136+
)
137+
else:
138+
# update the action with the new template
139+
# here we can assume the trigger is fully set up already
140+
client.update_action(
141+
name_id_or_prefix=action.id,
142+
configuration={
143+
"template_id": str(rt.id),
144+
"run_config": pop_restricted_configs(config)
145+
}
146+
)
101147

102148
else:
103149
llm_basic_rag.with_options(

llm-complete-guide/steps/finetune_embeddings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def finetune(
268268
tf32=False, # use tf32 precision
269269
bf16=False, # use bf16 precision
270270
batch_sampler=BatchSamplers.NO_DUPLICATES, # MultipleNegativesRankingLoss benefits from no duplicate samples in a batch
271-
eval_strategy="no", # evaluate after each epoch
271+
eval_strategy="epoch", # evaluate after each epoch
272272
save_strategy="epoch", # save after each epoch
273273
logging_steps=10, # log every 10 steps
274274
save_total_limit=3, # save only the last 3 models

0 commit comments

Comments
 (0)