Iterative ProcessIterate with inline scripts
Sometime users may want to execute a script in their operation or to generate a file that can be used as an input for an init container or the main container without cloning a repo.
Running a python script
This example shows how to initialize a python script without cloning a repo or uploading code:
version: 1.1
kind: component
run:
kind: job
init:
- file:
content: |
print("Hello World")
filename: script.py
container:
image: polyaxon/polyaxon-quick-start
workingDir: "{{ globals.artifacts_path }}"
command: [python3, -u, script.py]This example creates a file script.py in the init section and executes it in the main container.
Run the inline script
You can submit the complete Polyaxonfile above from the UI or the CLI.
Using the UI
In the quick-start project, open the create menu and select New job. Paste the Polyaxonfile into the editor, then select Create.

- Open the create menu and select New job.

- Paste the Polyaxonfile and create the job.
Using the CLI
Save the same Polyaxonfile as inline-script.yaml, then run:
polyaxon run -p quick-start -f inline-script.yaml -lSimilar to all other init containers, we could provide a custom path where the file should be initializer:
init:
- file:
content: |
print("Hello World")
filename: script.py
path: custom/path/to/useRunning a bash script
version: 1.1
kind: component
run:
kind: job
init:
- file:
content: |
echo 'This is a test.' | wc -w
filename: script.sh
chmod: "+x"
container:
image: polyaxon/polyaxon-quick-start
workingDir: "{{ globals.artifacts_path }}"
command: ['/bin/bash', '-c']
args: ['./script.sh']Initializing a YAML file
version: 1.1
kind: component
run:
kind: job
init:
- file:
content: |
version: 1.1
kind: component
run:
kind: job
init:
- file:
content: |
echo 'This is a test.' | wc -w
filename: script.sh
chmod: "+x"
container:
image: polyaxon/polyaxon-quick-start
workingDir: "{{ globals.artifacts_path }}"
command: ['/bin/bash', '-c']
args: ['./script.sh']
filename: polyaxonfile.yaml
chmod: "+x"
container:
image: polyaxon/polyaxon-cli
workingDir: "{{ globals.artifacts_path }}"
command: ['polyaxon', "check", '-f']
args: ['polyaxonfile.yaml']