Packaging local files into a Tesseract¶
Context¶
You may need to include local files into your Tesseract, e.g. if we want to load in pretrained model weights, or artifacts that we may need access to. This guide will demonstrate how.
Example Tesseract (examples/package_data)¶
In this example, we want to include and process parameters.json
file in our Tesseract.
In order to achieve this, we must modify the tesseract_config.yaml
file with the source (local path) and the target destinations (location in the Tesseract container).
build_config:
package_data:
- [parameters.json, parameters.json]
Now that it is included in the build config, we can use it in our Tesseracts apply function as normal.
def apply(inputs: InputSchema) -> OutputSchema:
dirname = os.path.dirname(__file__)
parameter_file = os.path.join(dirname, "parameters.json")
# check file exists
assert os.path.exists(parameter_file)
# check parameters
with open(parameter_file) as file:
data = json.load(file)
assert data == {"a": 1.0, "b": 100.0}
return OutputSchema()