Skip to content

Commit

Permalink
Add Docker image build and FlyteAgent update steps to "Developing age…
Browse files Browse the repository at this point in the history
…nts" doc (#5009)

* add docker image build and flyteagent update steps

Signed-off-by: nikki everett <[email protected]>

* fix link

Signed-off-by: nikki everett <[email protected]>

* remove old agents doc and redirect to new agents guide

Signed-off-by: nikki everett <[email protected]>

* update timeout

Signed-off-by: Kevin Su <[email protected]>

---------

Signed-off-by: nikki everett <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Co-authored-by: Kevin Su <[email protected]>
  • Loading branch information
neverett and pingsutw authored Mar 6, 2024
1 parent bce9b6f commit fd42f65
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 238 deletions.
82 changes: 80 additions & 2 deletions docs/flyte_agents/developing_agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ While agents can be written in any programming language, we currently only suppo
```

## Async agent interface specification
## Steps

### 1. Implement required methods

#### Async agent interface specification

To create a new async agent, extend the [`AsyncAgentBase`](https://github.com/flyteorg/flytekit/blob/master/flytekit/extend/backend/base_agent.py#L127) class and implement `create`, `get`, and `delete` methods. These methods must be idempotent.

Expand Down Expand Up @@ -76,7 +80,7 @@ AgentRegistry.register(BigQueryAgent())

For an example implementation, see the [BigQuery agent](https://github.com/flyteorg/flytekit/blob/master/plugins/flytekit-bigquery/flytekitplugins/bigquery/agent.py#L43).

## Sync agent interface specification
#### Sync agent interface specification

To create a new sync agent, extend the [`SyncAgentBase`](https://github.com/flyteorg/flytekit/blob/master/flytekit/extend/backend/base_agent.py#L107) class and implement a `do` method. This method must be idempotent.

Expand All @@ -98,3 +102,77 @@ class OpenAIAgent(SyncAgentBase):

AgentRegistry.register(OpenAIAgent())
```

### 2. Test the agent locally

See {doc}`"Testing agents locally" <testing_agents_locally>` to test your agent locally.

### 3. Build a new Docker image

The following is a sample Dockerfile for building an image for a Flyte agent:

```Dockerfile
FROM python:3.9-slim-buster

MAINTAINER Flyte Team <users@flyte.org>
LABEL org.opencontainers.image.source=https://github.com/flyteorg/flytekit

WORKDIR /root
ENV PYTHONPATH /root

# flytekit will autoload the agent if package is installed.
RUN pip install flytekitplugins-bigquery
CMD pyflyte serve agent --port 8000
```

:::{note}
For flytekit versions `<=v1.10.2`, use `pyflyte serve`.
For flytekit versions `>v1.10.2`, use `pyflyte serve agent`.
:::

### 4. Update FlyteAgent

1. Update the FlyteAgent deployment's [image](https://github.com/flyteorg/flyte/blob/master/charts/flyteagent/templates/agent/deployment.yaml#L35)
2. Update the FlytePropeller configmap.

```YAML
tasks:
task-plugins:
enabled-plugins:
- agent-service
default-for-task-types:
- bigquery_query_job_task: agent-service
- custom_task: agent-service

plugins:
agent-service:
supportedTaskTypes:
- bigquery_query_job_task
- default_task
- custom_task
# By default, all requests will be sent to the default agent.
defaultAgent:
endpoint: "dns:///flyteagent.flyte.svc.cluster.local:8000"
insecure: true
timeouts:
GetTask: 5s
defaultTimeout: 10s
agents:
custom_agent:
endpoint: "dns:///custom-flyteagent.flyte.svc.cluster.local:8000"
insecure: false
defaultServiceConfig: '{"loadBalancingConfig": [{"round_robin":{}}]}'
timeouts:
GetTask: 5s
defaultTimeout: 10s
agentForTaskTypes:
# It will override the default agent for custom_task, which means propeller will send the request to this agent.
- custom_task: custom_agent
```

3. Restart the FlytePropeller

```
kubectl rollout restart deployment flytepropeller -n flyte
```

234 changes: 0 additions & 234 deletions docs/user_guide/development_lifecycle/agents.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/user_guide/development_lifecycle/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ You will gain an understanding of concepts like caching, the Flyte remote API, A
:name: development_lifecycle_toc
:hidden:
agents
private_images
caching
cache_serializing
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/extending/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ of the plugin.

_New in Flyte 1.7.0_

{ref}`Flyte Agent Service <extend-agent-service>` allows you to write backend
The {ref}`Flyte Agent service <flyte_agents_guide>` allows you to write backend
plugins in Python.

### Summary
Expand Down

0 comments on commit fd42f65

Please sign in to comment.