sightline.simon.servable — Servable API

This class is not meant to be used directly, but its API is exposed for each Servable type. Import and use one of the specific Servable types, and use this API through that class instead of this one.

class sightline.simon.servable.Servable[source]

Attributes

  • Servable.id: str
  • Servable.name: str
  • Servable.description: str
  • Servable.tags: List[str]
  • Servable.created: datetime
  • Servable.status: V1Status
  • Servable.user_status: str
  • Servable.resources: Resources
  • Servable.config: Dict
  • Servable.url: str
  • Servable.capabilities: List[Capability]
  • Servable.dependencies: List[Prototype]
  • Servable.prototype: Optional[Prototype]
  • Servable.instances: List[Instance]
  • Servable.outputs: Dict[str, V1Resource]
  • Servable.derived_from: List[V1Resource]

Class Methods

  • Servable.prototypes()[source]

    Returns all of the Prototypes for this type of Servable.

    Classmethod

    Return type

    List[Prototype]

    Raises

    TypeError – if not called with an appropriate Servable class

  • Servable.list()[source]

    Returns all of the Servables of this type.

    Classmethod

    Return type

    List[Servable]

    Raises

    TypeError – if not called with an appropriate Servable class

  • Servable.from_id(id)[source]

    A constructor for Servables, looks up the Servable from its id.

    Classmethod

    Parameters

    id (str) –

    Return type

    Servable

    Raises
    • TypeError – if not called with an appropriate Servable class

    • V1Error – if no Servable with that id and type of class exists

  • Servable.create(prototype[, context=None][, config=None][, resources=None][, name=None][, description=''][, tags=None][, authenticate=True])[source]

    Creates a new Servable from a Prototype. The context can be a file or a directory and will be provided to Instances of this Servable. config values are specific to the Servable and used by Instances. resources specify how many Resources Kubernetes should allocate for Instances of this Servable. name, tags, and description are meant to be human readable and used for display purposes in the DTaaS frontend. If name is unspecified it defaults to the Servable id. Authentication can be disabled if it will be implemented manually for this Servable, or is otherwise not necessary.

    Many of the optional parameters either have an implicit default, or must be specified when running a Servable if they were not specified here. config and resources are mandatory before a Servable can be ran, but if not provided during Servable creation can be provided when calling run().

    Classmethod

    Parameters
    • prototype (str) – A Prototype id

    • context (Optional[str]) – A path to a context

    • config (Optional[Dict]) – A configuration dictionary for use by the Servable

    • resources (Optional[Resources]) – The Resources that Instances of this Servable require

    • name (Optional[str]) – The name of the Servable

    • description (str) – A description of the Servable

    • tags (Optional[List[str]]) – Tags for the servable

    • authenticate (bool) – Whether or not to enable authentication for the Servable

    Return type

    Servable

    Raises

    TypeError – if not called with an appropriate Servable class

  • Servable.remove(id)[source]

    Removes the Servable with the given id. The Servable must not be running.

    Classmethod

    Parameters

    id (str) – A Servable id to remove

    Return type

    None

    Raises

    TypeError – if not called with an appropriate Servable class

Methods

  • Servable.run([config=None][, resources=None][, public_key_path=None][, dev_domain=None])[source]

    config and resources inherit default values if they were specified during Servable creation, otherwise they must be specified here. If they are specified here and were specified during Servable creation, the values passed here take precedence.

    public_key_path and dev_domain should be specified together if desired. This will run SSH inside of the Instance and add your public key to its authorized_keys file, and expose it with a Kubernetes service. This is useful to be able to debug an Instance while it is running.

    The newly created Instance may have pending_capabilities that need to be granted before it can start. The URL for this request can be found in sightline.simon.instance.Instance.pending_capabilities and resolved with resolve_delegation_request().

    Parameters
    • config (Dict) – A configuration dictionary for use by the Instance

    • resources (Optional[Resources]) – The Resources that the Instance requires

    • public_key_path (str) – Path to your SSH public key

    • dev_domain (str) – Kubernetes service name for SSH

    Return type

    Instance

    Raises

    TypeError – if not called with an appropriate Servable class

  • Servable.stop(instance)[source]

    Stops the instance with the given id. The instance should be an instance of this Servable.

    Parameters

    instance (str) – The id of the Instance to stop

    Return type

    None

    Raises

    TypeError – if not called with an appropriate Servable class

  • Servable.update([name=None][, description=None][, tags=None][, user_status=None])[source]

    Updates the Servable with whichever fields are set. user_status provides a means for Instances to convey status information about their Servable. For example, a Pipeline could use user_status to convey progress about how far along it is in whatever it is doing. Instances of Servables by default have Capability to call update() on their Servable so that they can set user_status.

    Parameters
    • name (Optional[str]) – Changes the name of the Servable

    • description (Optional[str]) – Changes the description of the Servable

    • tags (Optional[List[str]]) – Changes the tags of the Servable

    • user_status (Optional[str]) – Sets the user_status field of the Servable