-
Docker tasks are limited, and we cannot pass custom kwargs into new APIClient. Do you think that Docker based Tasks could be more generic / abstract to handle all API endpoints? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@bukowa Yeah these could definitely be expanded upon! For example, the The task library is generally community-driven and we highly encourage contributions! 🙂 |
Beta Was this translation helpful? Give feedback.
-
What about something like that? import operator
import docker
from prefect import Task
class DockerTask(Task):
def __init__(self, client, method, **kwargs):
self.docker_func = operator.attrgetter(method)(client)
super().__init__(**kwargs)
def run(self, **kwargs) -> None:
return self.docker_func(**kwargs)
if __name__ == '__main__':
client = docker.client.APIClient()
task = DockerTask(
client=client,
method='containers',
)
task.run(all=True) |
Beta Was this translation helpful? Give feedback.
@bukowa Yeah these could definitely be expanded upon! For example, the
CreateContainer
task hasextra_docker_kwargs
for setting any custom kwargs that you want to forward to the Docker client:prefect/src/prefect/tasks/docker/containers.py
Line 27 in ce234bf
The task library is generally community-driven and we highly encourage contributions! 🙂