cortex get train-iris
# > endpoint: http://***.elb.us-west-2.amazonaws.com/train-iris
Submit a job
You can submit a job by making a POST request to the Task API's endpoint.
Using curl:
export TASK_API_ENDPOINT=<TASK_API_ENDPOINT> # e.g. export TASK_API_ENDPOINT=https://***.elb.us-west-2.amazonaws.com/train-iris
export DEST_S3_DIR=<YOUR_S3_DIRECTORY> # e.g. export DEST_S3_DIR=s3://my-bucket/dir
curl $TASK_API_ENDPOINT \
-X POST -H "Content-Type: application/json" \
-d "{\"config\": {\"dest_s3_dir\": \"$DEST_S3_DIR\"}}"
# > {"job_id":"69b183ed6bdf3e9b","api_name":"train-iris",...}
Or, using Python requests:
import cortex
import requests
cx = cortex.client("cortex") # "cortex" is the name of the Cortex environment used in this example
task_endpoint = cx.get_api("train-iris")["endpoint"]
dest_s3_dir = # S3 directory where the model will be uploaded, e.g. "s3://my-bucket/dir"
job_spec = {
"config": {
"dest_s3_dir": dest_s3_dir
}
}
response = requests.post(task_endpoint, json=job_spec)
print(response.text)
# > {"job_id":"69b183ed6bdf3e9b","api_name":"train-iris",...}
Monitor the job
cortex get train-iris 69b183ed6bdf3e9b
View the results
Once the job is complete, you should be able to find the trained model in the directory you've specified.