Help Center/
ModelArts/
FAQs/
Training Jobs/
Compiling the Training Code/
How Do I Invoke a Shell Script in a Training Job to Execute the .sh File?
Updated on 2022-12-06 GMT+08:00
How Do I Invoke a Shell Script in a Training Job to Execute the .sh File?
ModelArts enables you to invoke a shell script, and you can use Python to invoke .sh. The procedure is as follows:
- Upload the .sh script to an OBS bucket. For example, upload the .sh script to /bucket-name/code/test.sh.
- Create the .py file on a local PC, for example, test.py. The background automatically downloads the code directory to the /home/work/user-job-dir/ directory of the container. Therefore, you can invoke the .sh file in the test.py boot file as follows:
import os os.system('bash /home/work/user-job-dir/code/test.sh')
- Upload test.py to OBS. Then the file storage path is /bucket-name/code/test.py.
- When creating a training job, set the code directory to /bucket-name/code/, and the boot file directory to /bucket-name/code/test.py.
After the training job is created, you can use Python to invoke the .sh file.
Parent topic: Compiling the Training Code
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot