This job prints two messages with a time sleep of three seconds between. You could
save the code into a single hello_world_job.py file, and then run
it as a job. Job runs already provide Python preinstalled, and can run the code with
all Python system libraries.
This example doesn't use third-party Python libraries. You control the installed
Python libraries and environments by using your job in a conda environment.
Bash or Shell Scripts 🔗
You can use a single script file as in this example or more complex one:
#!/bin/bash
var=$1
if [ -z "$var" ]
then
echo "no argument provided"
exit 100
else
while [ "$1" != "" ]; do
echo "Received: ${1}" && shift;
done
fi
These types of job runs are run using Oracle Linux.
zip or Compressed Tar Files 🔗
Often your projects are more complex and require more code than is feasible in a
single file. If you have complex Python project and shell scripts, you can archive
the entire body of content and run it as job. Using a fat JAR file, you can run Java
code as a job.
There aren't special requirements about how to write your Python code or shell script to run it as a job. You can point to your main file using the JOB_RUN_ENTRYPOINT parameter after you upload the zip or compressed tar artifact.
The zip and compressed tar artifacts can also have a runtime YAML file that sets the
required job run environment variables.
Archive file considerations:
All your code must be archived under a root directory.
The file name should match the root directory name that you set with JOB_RUN_ENTRYPOINT.
The JOB_RUN_ENTRYPOINT appears in the Job Runs Details page
when it's in use.
Don't change the name of the archive file after you compress your
directory.
Get started with the sample by downloading, unzipping, and examining the zipped_python_job.zip file.
The zip file contains a simple logging job which is archived into a zip file under
the zipped_python_job/ directory. You can run the job by specifying
the location of the main python file by setting the
JOB_RUN_ENTRYPOINT environment variable, either in the OCI
Console or using the OCI SDK:
Create your job code under the root directory. The job code in its entirety must be under the root directory.
Compress the root directory to a zip or tar file.
Now you can upload the archive file as a job artifact when you
create a job. When creating the job, add the
JOB_RUN_ENTRYPOINT as a custom environment variable in the job
configuration.