exopy.app.dependencies.dependencies module

Extension used to declared dependencies on some objects for execution or rebuilding of an existing structure.

Dependencies allows to collect before hand (when the full workbench is available) as set of of objects (classes, definitions, …) and then use it later to in a workbench free environment to rebuild or execute some code. Those mechanisms are used to collect task classes (build) and also drivers classes and intsrument profiles (runtime)

class exopy.app.dependencies.dependencies.BuildDependency(parent=None, **kwargs)[source]

Bases: enaml.core.declarative.Declarative

Build dependencies are used to rebuild exopy structures.

If a plugin manage objects used to build a structure that can be saved to a config file it should declare a BuildDependency extension and contribute it to the ‘build-dependencies’ extensions point of the DependenciesPlugin (exopy.app.dependencies).

id

Unique id for this extension. Should match the dep_type attribute value of the object it is meant for.

analyse(workbench, obj, getter, dependencies, errors)[source]

Analyse the identified build dependencies and list runtime ones.

This method should never raise an error but rather use the errors dictionary to signal any issue.

Parameters
  • workbench (enaml.workbench.api.Workbench) – Reference to the application workbench.

  • obj – Object whose build dependencies should be analysed and runtime ones identified.

  • getter (callable(obj, name)) – Callable to use to access obj attribute. Attribute must be accessed using this function rather than the usual ‘.’ syntax as the passed object might be a dictionary like object.

  • dependencies (set) – Set in which to list the dependencies.

  • errors (dict) – Dictionary in which to write the errors that occured during collection.

Returns

runtime_collectors – List of runtime dependencies that this object have.

Return type

list

validate(workbench, dependencies, errors)[source]

Validate that all the dependencies exists.

This method is not intended to query the actual dependencies but simply to assert that they are theoretically available from the manager plugin. This method should never raise an error but rather use the errors dictionary to signal any issue.

Parameters
  • workbench (enaml.workbench.api.Workbench) – Reference to the application workbench.

  • dependencies (set) – Set of depedencies to validate.

  • errors (dict) – Dictionary in which to write the errors that occured during collection.

collect(workbench, dependencies, errors)[source]

Collect build dependencies.

This method should never raise an error but rather use the errors dictionary to signal any issue.

Parameters
  • workbench (enaml.workbench.api.Workbench) – Reference to the application workbench.

  • dependencies (dict) – Dictionary whose values are initialised to None listing the dependencies to collect.

  • errors (dict) – Dictionary in which to write the errors that occured during collection.

class exopy.app.dependencies.dependencies.RuntimeDependencyAnalyser(parent=None, **kwargs)[source]

Bases: enaml.core.declarative.Declarative

Runtime dependencies are ressources needed at runtime by some structure (ex: tasks using instrument need at runtime the driver class and the instrument profile to work correctly).

id

Unique id for this extension.

collector_id

Id of the collector that should be used to collect the dependencies discovered during analysis.

analyse(workbench, obj, dependencies, errors)[source]

Analyse the identified runtime dependencies of an object.

This method should never raise an error but rather use the errors dictionary to signal any issue.

Parameters
  • workbench (enaml.workbench.api.Workbench) – Reference to the application workbench.

  • obj – Object whose runtime dependencies should be analysed.

  • dependencies (set) – Set in which to list the dependencies.

  • errors (dict) – Dictionary in which to write the errors that occured during collection.

class exopy.app.dependencies.dependencies.RuntimeDependencyCollector(parent=None, **kwargs)[source]

Bases: enaml.core.declarative.Declarative

Runtime dependencies are ressources needed at runtime by some structure (ex: tasks using instrument need at runtime the driver class and the instrument profile to work correctly).

id

Unique id for this extension.

validate(workbench, dependencies, errors)[source]

Validate that all the dependencies exists.

This method should try to access the dependencies but simply assert that they exist. This method should never raise an error but rather use the errors dictionary to signal any issue.

Parameters
  • workbench (enaml.workbench.api.Workbench) – Reference to the application workbench.

  • dependencies (set) – Set of depedencies to validate.

  • errors (dict) – Dictionary in which to write the errors that occured during collection.

collect(workbench, owner, dependencies, unavailable, errors)[source]

Collect the identified runtime dependencies.

This method should never raise an error but rather use the errors dictionary to signal any issue.

If some of them requires some kind of permission, this permission should be required.

Parameters
  • workbench (enaml.workbench.api.Workbench) – Reference to the application workbench.

  • owner (unicode) – Calling plugin id . Used for some runtime dependencies needing to know the ressource owner.

  • dependencies (dict) – Dictionary whose values are initialised to None listing the dependencies to collect.

  • unavaible (set) – Set of resources that could not be provided because they are currently unavailable.

  • errors (dict) – Dictionary in which to write the errors that occured during collection.

release(workbench, owner, dependencies)[source]

Release resources previously collected.

This makes sense only if the ressource requires some kind of permissions.

Parameters
  • workbench – Reference to the application workbench.

  • owner (unicode) – Id of the plugin releasing the ressources.

  • dependencies (iterable) – Iterable of dependencies that are no longer needed.