deploy.py
file in the same directory as your Job code (app.py
). This file will contain the necessary configuration for your Job.
Your directory structure will then appear as follows:
File Structure
deploy.py
Deploy Training Code as a Job
Setup the project
argparse
from Python’s standard library.logging
from Python’s standard library.Build
, PythonBuild
, Service
, Resources
, and Port
) from servicefoundry
.servicefoundry
logs by configuring the log level to INFO
.Setup Job
Job
:name
of the job, which will be its identifier in TrueFoundry’s deployments dashboard.image
with instructions on how to build the container image.resources
for the application.Define Code to Docker Image Build Instructions
Build
class:build_source
to determine the source code location. If not provided, the current working directory is used.build_spec
using the PythonBuild
class to set up a Python environment.Configure the Python Build
PythonBuild
class, provide the following arguments:command
: The command to start your service.requirements_path
: The path to your dependencies file.Specify resource constraints.
Resources
class. This ensures proper deployment on the cluster.cpu_request
: Specifies the minimum CPU reserved for the application (0.5 represents 50% of CPU resources).cpu_limit
: Defines the upper limit on CPU usage, beyond which the application is throttled.memory_request
: Specifies the minimum required memory (e.g., 1 means 1 MB).memory_limit
: Sets the maximum memory allowed; exceeding this limit triggers an Out of Memory (OOM) error.Specifying environment variables
{"env_var_name": "env_var_value"
. This is helpful for configurations like environment type (dev/prod) or model registry links.Deploy the job
job.deploy()
to initiate the deployment. Provide the workspace_fqn
(fully qualified workspace name) to specify where the service should be deployed.train.py
and requirements.txt
files.
train.py
and requirements.txt
files.deploy.py
). The .tfyignore
file follows the same rules as the .gitignore
file.If your repository already has a .gitignore
file, you don’t need to create a .tfyignore
file. Service Foundry will automatically detect the files to ignore.Place the .tfyignore
file in the project’s root directory, alongside deploy.py.DEPLOY_SUCCESS:
, indicating a successful deployment.
You can find the application on the dashboard:
. Click that link to access the deployment dashboard.