Skip to content

truefoundry/train-iris-job

Repository files navigation

Train Iris Classification Model

This example trains an Iris Classification model

Run Locally

  1. Install requirements
python -m pip install -r requirements.txt
  1. Run the training script
python train.py

Deploy with TrueFoundry

  1. Install truefoundry
python -m pip install -U truefoundry
  1. Login
tfy login --host <TrueFoundry Platform URL>
  1. Add a deploy.py
  • Edit your workspace_fqn (Docs)
import logging
import argparse

from truefoundry.deploy import (
    Build,
    DockerFileBuild,
    Image,
    LocalSource,
    Port,
    PythonBuild,
    Job,
    Resources
)

logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")

job = Job(
    name="train-iris-job",

    # --- Build configuration i.e. How to package and build source code ---

    # This will instruct Truefoundry to automatically generate the Dockerfile and build it
    image=Build(
        build_source=LocalSource(local_build=False),
        build_spec=PythonBuild(
            requirements_path="requirements.txt",
            command="python train.py"
        )
        # Alternatively, you can also use DockerFileBuild to use the written Dockerfile like follows:
        # build_spec=DockerFileBuild()
    ),
    # Alternatively, you can use an already built public image of this codebase like follows:
    # image=Image(image_uri="...")

    # --- Environment Variables ---
    env={},

    # --- Resources ---
    resources=Resources(
        cpu_request=0.5, 
        cpu_limit=0.5,
        memory_request=1000, 
        memory_limit=1000,
        ephemeral_storage_request=500, 
        ephemeral_storage_limit=500
    ),
    workspace_fqn="<Enter Workspace FQN>",
)

# Get your workspace fqn from https://docs.truefoundry.com/docs/workspace#copy-workspace-fqn-fully-qualified-name
job.deploy(workspace_fqn="<Enter Workspace FQN>", wait=False)
  1. Deploy!
python deploy.py

About

A example job that trains an iris classification model. Sample Job to deploy on TrueFoundry

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •