domino logo
Latest (5.5)
  • Tech Ecosystem
  • Get Started
  • Domino Cloud
  • Collaborate
  • Projects
  • Work with Data
  • Workspaces
  • Environments
  • Executions
  • Deploy Models and Apps
  • Model Monitoring
  • Organizations
  • Security and Credentials
  • Notifications
  • Download the Audit Log
  • Data Planes
  • Search
  • Domino CLI
  • Troubleshooting
  • Get Help
domino logo
About Domino
Domino Data LabKnowledge BaseData Science BlogTraining
User Guide
>
Environments
>
Customize Environments
>
Add or Modify File Handlers

Add or Modify File Handlers

Note

What is a file handler?

When you run a job, Domino automatically handles the execution of the file. In order to do that, Domino already has the list of commands to be run based on the file extension. See Supported File Types for the list of commands.

To execute a file extension that is not in the list, or to run a different command for a file extension that is in the list, you can use a file handler.

A file handler is a bash script with the name of the file extension (without the .sh extension), located in /opt/domino/handlers/{extension}.

Examples:
  • The file handler /opt/domino/handlers/jpeg targets files with the .jpeg extension.

  • The file handler /opt/domino/handlers/py overrides the default behavior for .py files.

The file handler lives in the environment’s file system, so the execution of the job depends on the environment in which you run the job.

Tip

Add a file handler through the Domino UI

To add a file handler through the Domino UI, you must edit an environment definition.

  1. Click Environments in the Domino sidebar.

  2. In the Dockerfile instructions field, create a directory for the custom file handler:

    RUN mkdir -p /opt/domino/bin/file-handlers
  3. Add the commands you want to execute when you invoke the file. Save the custom commands to a file with the same name as the file extension you want to target:

    RUN echo "#\!/bin/bash" >> /opt/domino/bin/file-handlers/<target-file-extension>
    RUN echo "<Line 1 of bash script>" >> /opt/domino/bin/file-handlers/<target-file-extension>
    RUN echo "<Line 2 of bash script>" >> /opt/domino/bin/file-handlers/<target-file-extension>
    ...

Add a file handler through the terminal

To add a file handler through the terminal, you must build a Docker image and upload it to an external repository. You can use the Docker image to create an environment that contains your file handler.

  1. Create a directory for the custom file handler:

    mkdir -p /opt/domino/bin/file-handlers
  2. Add the commands you want to execute when you invoke the file. Save the custom commands to a file with the same name as the file extension you want to target:

    RUN echo "#\!/bin/bash" >> /opt/domino/bin/file-handlers/<target-file-extension>
    RUN echo "<Line 1 of bash script>" >> /opt/domino/bin/file-handlers/<target-file-extension>
    RUN echo "<Line 2 of bash script>" >> /opt/domino/bin/file-handlers/<target-file-extension>
    ...
  3. Save a copy of this file to a Docker image:

    FROM {DOCKER_BASE_IMAGE}
    RUN mkdir -p /opt/domino/bin/file-handlers
    COPY <target-file-extension> /opt/domino/bin/file-handlers/
  4. Build the Docker image and upload it to an external repository associated with your project.

    docker build -t "repository/domino-env-with-executable-target" .
    docker push "repository/domino-env-with-executable-target"
Domino Data LabKnowledge BaseData Science BlogTraining
Copyright © 2022 Domino Data Lab. All rights reserved.