daemon.api.dependencies module

class daemon.api.dependencies.Environment(envs=Query([]))[source]

Bases: object

Parses environment variables to be set inside the containers

validate(envs)[source]

Validate and set env vars as a dict

Parameters

envs (List[str]) – list of env vars passed as query params

class daemon.api.dependencies.FlowDepends(workspace_id, filename, envs=Depends(Environment))[source]

Bases: object

Validates & Sets host/port dependencies during Flow creation/update

localpath()[source]

Validates local filepath in workspace from filename. Raise 404 if filepath doesn’t exist in workspace.

Return type

Path

Returns

filepath for flow yaml

property newfile: str

return newfile path in format <root-workspace>/<workspace-id>/<flow-id>_<original-filename>

Return type

str

Returns

return filepath to save flow config in

load_and_dump()[source]

every Flow created inside JinaD lives inside a container. It is important to know the list of ports to be published with localhost before actually starting the container.

  1. load the flow yaml here.
    • yaml is stored in workspace directory, so we’ll cd there

    • yaml might include env vars. so we’ll set them (passed via query params)

  2. build the Flow so that gateway gets added.
    • get the list of ports to be published (port_expose, port_in, port_out, port_ctrl)

    • ports need to be published for gateway & executors that are not ContainerRuntime or JinadRuntime based

    • Pod level args for ports are enough, as we don’t need to publish Pea ports

    • all the above Pods also run in docker, hence we set runs_in_docker

  3. save the Flow config.
    • saves port configs of all executors into the new yaml.

    • set JINA_FULL_CLI envvar, so that gateway args are also added.

    • save the config into a new file.

  4. pass this new file as filename to partial-daemon to start the Flow

Return type

None

property ports: daemon.models.ports.PortMappings

getter for ports

Return type

PortMappings

Returns

ports to be mapped

class daemon.api.dependencies.PeaDepends(workspace_id, pea, envs=Depends(Environment))[source]

Bases: object

Validates & Sets host/port dependencies during Pea creation/update

property host_in: str

host_in for the pea/pod

Return type

str

Returns

host_in

property host_out: str

host_out for the pea/pod

Return type

str

Returns

host_out

ports

The decorator to cache property of a class.

validate()[source]

# TODO (deepankar): These docs would need changes after dynamic routing changes. Validates and sets arguments to be used in store DOCKER_HOST = ‘host.docker.internal’

runtime_cls: ZEDRuntime

host_in, host_out: set to DOCKER_HOST, as it would talk to gateway/other pods ports: map port_in & port_out if socket_in & socket_out are BIND.

map port_ctrl, ignore port_exppse

runtime_cls: ContainerRuntime

host_in,`host_out`: don’t change. Handled interally in jina pod ports: handled internally in ContainerRuntime

runtime_cls: ZEDRuntime
host_in, host_out: set to DOCKERHOST

host config handled interally in jina pod wouldn’t work here, as they need to talk to head/tail peas which are on DOCKER_HOST

ports: don’t map port_in & port_out as they’re always CONNECT.

map port_ctrl??, ignore port_exppse

runtime_cls: ContainerRuntime or ZEDRuntime
host_in, host_out: set to DOCKERHOST

host config handled interally in jina pod wouldn’t work here, as they need to talk to head/tail peas which are on DOCKER_HOST

ports: handled internally in ContainerRuntime

runtime_cls: ZEDRuntime (always??)

host_in, host_out: set to DOCKER_HOST, as they would talk to gateway/other pods. ports: map port_in & port_out if socket_in & socket_out are BIND.

map port_ctrl, ignore port_exppse

TODO: check the host_in/host_out for CONNECT sockets TODO: HEAD/TAIL - can uses_before or uses_after be docker://

class daemon.api.dependencies.PodDepends(workspace_id, pod, envs=Depends(Environment))[source]

Bases: daemon.api.dependencies.PeaDepends

Validates & Sets host/port dependencies during Pod creation/update

class daemon.api.dependencies.WorkspaceDepends(id=None, files=File(None))[source]

Bases: object

Interacts with task queue to inform about workspace creation/update