You can configure projects that import files and/or environment variables from other projects. This allows you to factor your team’s analyses into reusable building blocks, and avoid unnecessary repetition/duplication of information.
- A canonical dataset used by multiple projects can be managed in a single place.
- Your code can reside independently of your data. No need to duplicate/sync large datasets within multiple projects on your local machine.
- An external data source requiring login credentials (such as a database) may be securely represented via environment variables in a single project, and then used by many projects.
- Results from one model (such as trained model files, or R workspaces/installations) can be imported and utilized by multiple different downstream projects.
- If a project's files are organized as an R or Python package, then you can configure other projects to automatically install them at runtime.
How it works
You can configure projects to "export" files and/or environment variables they define.
Other projects can import those projects which export something (setup instructions below). After you’ve done so, files and/or environment variables from those projects are accessible when you run code in the importing project.
During runs with imported files, each project directory is located at
/mnt/<username>/<project name>, where
<username> is the owner of that particular project. Imported directories are read-only.
WARNING: The path of your main project will also change from
/mnt/<username>/<project name>. If you have hardcoded any paths in your projects to
/mnt, we recommend replacing the hardcoded paths to using the
$DOMINO_WORKING_DIR environment variable. This will ensure the correct path regardless of whether other projects are imported. See the support article on Domino Environment Variables for more information.
- Make sure you have Owner, Collaborator, or Project Importer access to the project(s) from which you wish to import data.
- For each of these projects, visit it in the UI, and click "Exports" on the lower left sidebar. Under “Exports”, check “Files” and/or "Environment variables", depending on which you wish to import. To export as a package, select the appropriate language from the "Code Package" dropdown.
- Now go to the project into which data will be imported. Choose "Files" from the left sidebar. Under imports, add the project(s) using the format
Any imported environment variables will be displayed on that page also:
NOTE: Only the files from the directly imported project will be viewable when you import. For example if project "A" is imported into project "B", and then your project imports "B" then only the contents of "B" will be accessible addition to your own project's files.
Running python scripts from imported project
When running a Python script from an imported project you may encounter the error message:
FileNotFoundError: [Error 2] No such file or directory:
When a python script runs an import, it executes that code with the current working directory, so if you have a relative path in the imported file, it will try to find the file in the current folder and fail. In this case, you can update your imported script to use an absolute path based on the current path of the imported file using os.path, eg.
import os file_name = os.path.join(os.path.dirname(__file__), 'your_referenced_file.dat')