Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs][flyteagent] Improve Agent Secret Setup #5765

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

Future-Outlier
Copy link
Member

@Future-Outlier Future-Outlier commented Sep 21, 2024

Docs link

Tracking issue

#3936

What changes were proposed in this pull request?

  1. use kubectl patch secret to set the secret value in the agent deployment.
  2. add kubectl rollout restart deployment flyteagent -n flyte after the secret is set

How was this patch tested?

ChatGPT Agent.

from flytekit import workflow
from flytekitplugins.openai import ChatGPTTask

chatgpt_small_job = ChatGPTTask(
    name="3.5-turbo",
    chatgpt_config={
        "model": "gpt-3.5-turbo",
        "temperature": 0.7,
    },
)

chatgpt_big_job = ChatGPTTask(
    name="gpt-4",
    chatgpt_config={
        "model": "gpt-4",
        "temperature": 0.7,
    },
)


@workflow
def my_chatgpt_job(message: str) -> str:
    message = chatgpt_small_job(message=message)
    message = chatgpt_big_job(message=message)
    return message

Setup process

  1. start flyte sandbox
flytectl demo start --force
  1. set your secret
SECRET_VALUE=$(echo -n "<OPENAI_API_TOKEN>" | base64) && \
  kubectl patch secret flyteagent -n flyte --patch "{\"data\":{\"flyte_openai_api_key\":\"$SECRET_VALUE\"}}"
  1. restart your agent deployment
kubectl rollout restart deployment flyteagent -n flyte
  1. run the agent workflow
pyflyte run --remote  build/PR/agent/openai_chatgpt.py my_chatgpt_job --message hi

Screenshots

image image

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Copy link

codecov bot commented Sep 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.30%. Comparing base (28f65b3) to head (4667d80).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5765   +/-   ##
=======================================
  Coverage   36.30%   36.30%           
=======================================
  Files        1305     1305           
  Lines      110000   110000           
=======================================
  Hits        39932    39932           
  Misses      65912    65912           
  Partials     4156     4156           
Flag Coverage Δ
unittests-datacatalog 51.37% <ø> (ø)
unittests-flyteadmin 55.62% <ø> (ø)
unittests-flytecopilot 12.17% <ø> (ø)
unittests-flytectl 62.21% <ø> (ø)
unittests-flyteidl 7.12% <ø> (ø)
unittests-flyteplugins 53.35% <ø> (ø)
unittests-flytepropeller 41.89% <ø> (ø)
unittests-flytestdlib 55.21% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


echo -n "<OPENAI_API_TOKEN>" | base64
SECRET_VALUE=$(echo -n "<OPENAI_API_TOKEN>" | base64) && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks great, thanks!

@pingsutw pingsutw merged commit 5ad4195 into master Sep 23, 2024
50 checks passed
@pingsutw pingsutw deleted the agent-edit-secret-all-use-kubectl-set branch September 23, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants