Submit a Notebook as a Job
Simple Usecase
The working group's Group Volume is required.
Select API Token from the extension and add your own token. See How to generate a API Token.
Launch Notebook instance from User Portal by using a base image from InfuseAI or a image built on top of a base image from InfuseAI.
Enter the Group Volume directory of the current working group, open an empty notebook file there.
If the notebook is not located in the group volume, you may see "Now, we only support notebook under group volume. Please move your noteobook into your group volume." when submitting it.
Add two cells.
!pip install camelcase
Here we comment out
start=1
&end=10
because we will feed the parameters into notebook later.import time import camelcase camel = camelcase.CamelCase() txt = "this method capitalizes the first letter of each word." #start = 1 #end = 10 print("Counting from 1 to 10:") for num in range(start, end + 1): time.sleep(1) print('{}: {}'.format(num, camel.hump(txt)))
Select Submit Notebook as Job from the extension
- Select Instance Type for the Job.
- Select Image for the instance. (Use a base image from InfuseAI or a image built on top of a base image from InfuseAI)
- Fill in Job Name you want.
- Fill in Notebook Parameters
start=1; end=r10
.(using;
as separator, new line is not allowed.) - Submit.
View the job status by clicking the link.
Once the job succeeded, go back to Notebook. There is a generated notebook file with the result beside the original notebook file. We can notice the parameter we gave is inserted as the first cell.
Output Job Artifacts
Since a Notebook is submitted as a Job, the output data generated by the job can be stored as job artifacts. See Job Artifact.
Replace the 2nd cell with cells below.
Create the artifacts directory.
!mkdir -p artifacts/
This sample code will open a new file hello_artifact.txt
under the artifacts/
and write the output in.
import time
import camelcase
camel = camelcase.CamelCase()
txt = "this method capitalizes the first letter of each word."
start = 1
end = 10
art = open("artifacts/hello_artifact.txt", "w")
print("Counting from 1 to 10:")
for num in range(start, end + 1):
time.sleep(1)
print('{}: {}'.format(num, camel.hump(txt)))
art.write('{}: {}\n'.format(num, camel.hump(txt)))
art.close()
Submit this Notebook as another job, once the job succeeded, hello_artifact.txt
will be listed from Job.
We also can find it /phfs/jobArtifacts/job-<ID>/hello_artifact.txt
from Notebook.