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 newname: str

    Return newfile path in following format flow.yml -> <root-workspace>/<workspace-id>/<flow-id>_flow.yml flow1.yml -> <root-workspace>/<workspace-id>/<flow-id>_flow1.yml src/flow.yml -> <root-workspace>/<workspace-id>/src/<flow-id>_flow.yml src/abc/flow.yml -> <root-workspace>/<workspace-id>/src/abc/<flow-id>_flow.yml

    • Return type

      str

      Returns

      newname for the flow yaml file

  • property newfile: str

    Return newfile path fetched from newname

    • 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)

  1. 4. build the Flow so that gateway gets added.
  2. - get the list of ports to be published (port\_expose, port\_in, port\_out, port\_ctrl)
  3. - ports need to be published for gateway & executors that are not ContainerRuntime or JinadRuntime based
  4. - Deployment level args for ports are enough, as we dont need to publish Pod ports
  5. 6. save the Flow config.
  6. - saves port configs of all executors into the new yaml.
  7. - set JINA\_FULL\_CLI envvar, so that gateway args are also added.
  8. - save the config into a new file.
  9. 7. pass this new file as filename to partial-daemon to start the Flow
  10. - Return type
  11. `None`

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

Bases: object

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

  • ports

    The decorator to cache property of a class.

  • update_args()[source]

    TODO: update docs

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

Bases: daemon.api.dependencies.PodDepends

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