Packages
Last updated
Last updated
Packages organize and provide the nodes that can be included in a graph. All Ana packages are standard Python packages. They can be added to the channel from the Python Package Index (PyPI), included as a submodule from a git repository, or as source code stored directly in the channel directory.
Ana packages are added to the channel by including them in the “requirements.txt” file in the channel root directory. Here is an example of a requirements.txt file that adds two packages to the channel.
The “anatools” package is required for all channels as it provides the base capabilities for Ana. In this example, the anatools package will be added from PyPI.
The second package in the example is “testpkg1”. The source code for this package is located in the “packages/testpkg1” subdirectory. This package can either be a git submodule or it can be source code. Note in this example we included the “-e” option which installs the package in editable mode (see PIP options for details). The -e option is useful during package development but is not necessary for a stable production channel where the package code does not change.
Package source code is stored in the “packages” subdirectory under the channel root. Each package is stored in a separate subdirectory that is named after the package. Each package includes a setup.py file so that it can be installed in the channel.
Here is an example of the directory structure for a package called “example”.
The setup.py file needs to include yml files in its package data. Here is the setup file for the example package:
The example package directory itself contains two subdirectories - nodes and lib - and two files - __init__.py and package.yml.
The “nodes” directory contains the Python source code for all nodes in the package as well as schema files for each node. For every node module, there is a corresponding schema file. Schema files are in YAML format.
The “lib” directory contains Python modules that are used by nodes. This may include base classes, support functions, and other code that is called by a node.
The “__init__.py” is empty. It is required and indicates the directory contains a Python package.
The “package.yml” file is configuration information for the package. The content of this file is package specific, however there are two top level sections that most channels implement - “volumes” and “objects”. Here is a portion of the package.yml file for the example package:
The “objects” section is a dictionary that defines Blender objects used by the channel. The object type is the key and the value is package-specific configuration information for the object. Most channels implement the “filename” attribute which specifies the location of the blender file containing the object. This can be an absolute path, a relative path (relative to the --data directory) or it can be prepended by a volume name followed by a colon.
The “volumes” section is a dictionary that defines data volumes used by the package. The name of the volume is the key and the value is the volume ID.