Project dependencies

You can configure projects to import files and environment variables from other projects. This allows you to use your team’s existing work as reusable building blocks, and avoid unnecessary repetition.

For example:

  • A canonical dataset used by multiple projects can be managed in a single place.
  • Your code can reside in a separate project from your data. No need to duplicate large datasets within multiple projects.
  • 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) can be imported and used 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

The first step is to configure the exporting project. Projects can export files and / or environment variables. 

Other projects can import content from projects that are configured for export. After you’ve set up import, the content from the exporting projects is 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. 

  Note

The path of your main project will also change from /mnt to /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.

Setup 

  1. First, you need to set up the projects you want to export from. You need to have Owner, Collaborator, or Project Importer access to the projects to set them up for export.
  2. To set up export, open the project in Domino and click Settings from the project menu, then open the Exports tab. In the panel on that tab, click the checkbox for files or environment variables to make those types of content available to other projects. To export as a package, select the appropriate language from the Code Package dropdown.

    Screen_Shot_2018-10-26_at_12.32.24_PM.png
  3. Next, open the project into which you want to import content. Click Files from the project menu, then open the Other Projects tab. Add projects by filling in the project name field, then clicking Import. You'll see projects currently being imported listed in a table below.

    Screen_Shot_2018-10-26_at_12.39.16_PM.png

 

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, only the contents of B will be accessible addition to your project.

Troubleshooting

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')
Was this article helpful?
2 out of 2 found this helpful