Build a trial image
A trial image contains your program, its dependencies, and the command that evaluates one parameter set. HyperOptimizer supplies the parameter values, starts the container, and collects its output.
For a complete program to copy, start with the quickstart. This guide explains how to package your own.
Build the image
Section titled “Build the image”Keep your Dockerfile, requirements.txt, and main.py in the build directory. Pin dependency versions in requirements.txt; omit its COPY and RUN instructions if your program has no external dependencies.
FROM python:3.12-slimWORKDIR /appCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txtCOPY main.py .ENTRYPOINT ["python", "-u", "main.py"]Copy any required data or other source files explicitly. For repeatable production builds, also pin the base image by digest.
ENTRYPOINT and CMD
Section titled “ENTRYPOINT and CMD”Put the executable in an exec-form ENTRYPOINT. HyperOptimizer supplies container arguments, which replace the image’s CMD while keeping its entrypoint. This is also how docker run IMAGE ARGS behaves. See the Dockerfile reference.
| Your image | Trial arguments must contain |
|---|---|
ENTRYPOINT ["python", "-u", "main.py"] |
Just the program’s flags, such as --hpo-x=2. |
Only CMD ["python", "main.py"] |
The executable and script as well as the flags, such as python main.py --hpo-x=2. |
ENTRYPOINT ["python"] and CMD ["main.py"] |
The script name and flags, such as main.py --hpo-x=2. |
If you keep a CMD-only image, include the executable and script in fixedArgs or the dashboard command. Check the command preview before launch. A custom command template replaces the full argument list.
Test the exact command
Section titled “Test the exact command”For the entrypoint shown above, build and run with parameters your program accepts:
docker buildx build --platform linux/amd64 --load -t my-workload:v1 .docker run --rm --platform linux/amd64 my-workload:v1 --hpo-learning-rate=0.01Check that the container runs without prompts, prints every configured objective as a finite numeric metric, and exits with code 0. Try a second parameter value to confirm that it changes the computation.
Make inputs reproducible
Section titled “Make inputs reproducible”- Install dependencies at build time, rather than downloading them for every trial.
- Include the dataset in the image or arrange explicit, repeatable runtime access. Files on your laptop are not automatically mounted in cloud trials.
- Pass secrets as runtime environment variables. Keep
.env, credentials,.git, and.hpoout of the build context with.dockerignore. - Use a fixed dataset version and seed for comparisons. Log those identifiers without exposing secrets.
- Use trial-specific paths for external writes.
HYPEROPTIMIZER_TRIAL_IDis available in every trial.
The standard machines are CPU machines. Choose memory and runtime limits based on a measured local run; see machine sizes.
Next step
Section titled “Next step”Publish your image, then create an experiment. The container reference is a compact checklist for reviewing an existing image.