Help Center> ModelArts> FAQs> Training Jobs> Compiling the Training Code> How Do I Obtain the Path for Storing the Dependency File in Training Code?
Updated on 2022-09-19 GMT+08:00

How Do I Obtain the Path for Storing the Dependency File in Training Code?

The code developed locally must be uploaded to the ModelArts backend. In training code, it is error-prone to set the path for storing the dependency file.

The following general solution is recommended: Use the OS API to obtain the absolute path of the dependency file.

Example:

|---project_root                # Root directory for code
     |---bootfile.py            # Boot file
   |---otherfileDirectory       # Directory of other dependency files
     |---otherfile.py           # Other dependency files
    

Do as follows to obtain the path of the dependency file, otherfile_path in this example, in the boot file:

import os
current_path = os.path.dirname(os.path.realpath(__file__)) # Directory where the boot file is located
project_root = os.path.dirname(current_path) # Root directory of the project, which is the code directory set on the ModelArts training console
otherfile_path = os.path.join(project_root, "otherfileDirectory", "otherfile.py")

Compiling the Training Code FAQs

more