YanokWorker Contract
Task Template Contract for third-party developer integration
Overview
This contract defines an interface between a third-party engineer's code and Yanok's internal system that executes this code. It defines input parameters and output results so that each individual script (worker) can interface with one another properly.
Developer Requirements
- • Provide a base Docker image
- • Define required inputs
- • Define required secrets
- • Write to defined output locations
Base Image
Foundation requirements for worker templates
A template is built from another base image. The Docker image must have ENTRYPOINT defined.
FROM node:18-alpine WORKDIR /app COPY . . RUN npm install ENTRYPOINT ["node", "index.js"]
Inputs
How developers define and access required input data
Developer's script can define required inputs by providing a variable name. The value passed into the script will be a location of the file which the script will need to read and import.
Example Workflow
1. Developer Specifies
BASE_QUERY2. System Sets Environment
BASE_QUERY_PATH=/state/base_query.txt3. Script Reads Content
/state/base_query.txt will contain the contents of the required variable, which the script must read in.
Secrets
Secure handling of API keys and sensitive data
Secrets such as API keys can be passed into the container by specifying them in the interface. Secrets can be accessed via environment variables.
Example Implementation
Developer Specifies
OPENAI_KEYAvailable in Container
OPENAI_KEY=XXXXSecurity Note: Secrets are securely injected as environment variables and should never be hardcoded in the image or logged.
Output
How to write results for the next step in the workflow
OUTPUT_PATH is provided to the container. Developer must write anything to be passed on to the next step into the specified filepath.
Code Example
// Read the OUTPUT_PATH environment variable const outputPath = process.env.OUTPUT_PATH; // Process your data const result = processData(inputData); // Write result to the specified path fs.writeFileSync(outputPath, JSON.stringify(result));
Contract Summary
Base Image
Docker image with ENTRYPOINT defined
Inputs
File paths via environment variables
Secrets
API keys via environment variables
Output
Write to OUTPUT_PATH location
For more documentation and examples, visit the Yanok Documentation