> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getcollate.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Drive Connector | Build and Extend Custom Connectors Easily

> Learn how to create a Custom Drive Connector to ingest metadata from file system-like services into Collate using the ingestion framework.

# Custom Drive Connector

Just like other services (Database, Pipelines, Dashboards, Messaging, and so on), it’s possible to create a **Custom Drive Connector** to bring metadata from a storage or file system-like service into Collate.

This guide walks through how to implement your own Custom Drive Connector by extending the ingestion framework. The implementation pattern follows other service types closely, making the transition smooth for anyone familiar with the ecosystem.

> [!TIP]
>
> This guide is based on a working example in the OpenMetadata Demos repository: [link](https://github.com/open-metadata/openmetadata-demo/tree/main/custom-connector).

Watch Collate's Webinar on Custom Connectors to get more context on how to build these integrations.

[YouTube video player](https://www.youtube.com/embed/fDUj30Ub9VE?si=h1F_tckA_45V2ux3)

## Steps to Set Up a Custom Drive Connector

### Step 1 - Prepare Your Drive Connector

A Custom Drive Connector is a Python class that inherits from:

```python theme={null}

from metadata.ingestion.api.steps import Source

```

It must implement required methods such as:

* `prepare`
* `_iter`
* `test_connection` (optional but recommended so the UI can validate access)

```python theme={null}

custom_drive/
  my_drive_connector.py

```

**Inside** `my_drive_connector.py`, **define your class**:

```python theme={null}

class MyDriveConnector(Source):
    ...
    def _iter(self):
        ...

```

> [!TIP]
>
> `_iter` is a generator that produces the `CreateEntityRequest` instances expected by the ingestion framework.

For more information about the ingestion framework, see the [external ingestion guide](https://docs.getcollate.io/deployment/ingestion/external).

### Step 2 - Yield Drive Data as Entities

You need to yield `CreateEntityRequest` objects wrapped in an `Either` type. This pattern handles both successful entity creation and errors.

**Import necessary types**:

```python theme={null}

from metadata.ingestion.api.models import Either, StackTraceError
from metadata.generated.schema.api.data.createDirectory import CreateDirectoryRequest
from metadata.generated.schema.api.data.createFile import CreateFileRequest
from metadata.generated.schema.api.data.createSpreadsheet import CreateSpreadsheetRequest
from metadata.generated.schema.api.data.createWorksheet import CreateWorksheetRequest

```

**Example usage**:

```python theme={null}

for directory in self.drive_client.list_directories():
    try:
        yield Either(
            right=CreateDirectoryRequest(
                name=directory.name,
                description=directory.description,
                parent=directory.parent_fqn,
                href=directory.href,
            )
        )
    except Exception as exc:
        yield Either(
            left=StackTraceError(
                name="Drive Directory Ingestion Error",
                error=str(exc),
                stack_trace=traceback.format_exc(),
            )
        )

for file_metadata in self.drive_client.list_files():
    yield Either(
        right=CreateFileRequest(
            name=file_metadata.name,
            description=file_metadata.description,
            fileFormats=file_metadata.file_formats,
            parent=file_metadata.parent_directory_fqn,
            size=file_metadata.size,
        )
    )
```

Extend the same pattern with `CreateSpreadsheetRequest` and `CreateWorksheetRequest` if your Drive service exposes those concepts.

### Step 3 - Package Your Custom Drive Connector

To use the connector, package it as a Python module. A minimal `setup.py` may look like:

```python theme={null}

from setuptools import setup, find_packages

setup(
    name="custom_drive_connector",
    version="0.1",
    packages=find_packages(),
    install_requires=[],
)

```

**Build the package**:

```bash theme={null}

python setup.py sdist

```

### Step 4 - Update the Ingestion Image

To run your Custom Drive Connector inside Docker (for example, with Airflow or directly from the UI), the ingestion image must include your module.

**Dockerfile example**:

```Dockerfile theme={null}

FROM openmetadata/ingestion:2.0.5

WORKDIR ingestion
USER airflow

COPY custom_drive custom_drive
COPY setup.py .
RUN pip install --no-deps .

```

This ensures that your code is baked into the ingestion container. Always align the ingestion image tag with the Collate version that is running your server/UI.

### Step 5 - Run Collate with Custom Image

If you're using Docker Compose, update your setup to use the new image.

```makefile theme={null}

run:
	docker compose -f docker-compose.yml up --build

```

### Step 6 - Configure Custom Drive in the Collate UI

1. Navigate to **Settings** > **Services**, and select **Drive** service.
2. Click **Add New Service** and select **Custom**.
3. Enter your Source Python Class as:

   ```python theme={null}

   custom_drive.my_drive_connector.MyDriveConnector

   ```

Ensure the full module path is specified so Collate can import the connector.

## Configure Metadata Agent and Schedule Ingestion

The **Metadata Agent** extracts directories, files, spreadsheets, and other structural metadata from your source and keeps your Collate catalog in sync. It powers discovery, lineage, and governance across your data assets.

When you click **Create & Deploy**, Collate automatically deploys a Metadata Agent for this service and triggers the first ingestion run. View its status and run history from the **Agents** tab on the service detail page.

To configure the additional Metadata Agent and schedule ingestion, follow these steps:

1. Navigate to **Settings** > **Services** and select the **Drives** service.

2. Select your service and click the **Agents** tab.

3. Click **Add Agent** and select **Metadata** from the dropdown.

   ![Add Metadata Agent](https://mintcdn.com/collatedocs/bv5oe4uRjuorTJO1/public/images/ai-2.0/connectors/metadata-ingestion/add-metadata-agent.png?fit=max\&auto=format\&n=bv5oe4uRjuorTJO1\&q=85\&s=accad7d1c4ddf209781bff851d51d464)

   For some services, the dropdown is not available and clicking **Add Agent** takes you directly to the agent configuration page.

4. On the **Configure Ingestion** page, do the following and click **Next**.

   * **Name this Ingestion**: Enter a unique, recognizable name for this ingestion pipeline.

     ![Name this Ingestion](https://mintcdn.com/collatedocs/bv5oe4uRjuorTJO1/public/images/ai-2.0/connectors/metadata-ingestion/metadata-agent-name.png?fit=max\&auto=format\&n=bv5oe4uRjuorTJO1\&q=85\&s=d5ec1f0f3742cadab8cd54c602c97239)

   * **Agent Setup**: Configure the core parameters for this agent. The following fields are available:

     | Field | Default | Description |
     | - | - | - |
     | Number of Threads | 1 | Number of threads to use for parallel drive ingestion. |
     | Mark Deleted Directories | On | Soft-delete directories in Collate when they are removed from the source. Associated entities like files, spreadsheets, worksheets, and lineage are also deleted. |
     | Mark Deleted Files | On | Soft-delete files in Collate when they are removed from the source. Associated entities like lineage are also deleted. |
     | Mark Deleted Spreadsheets | On | Soft-delete spreadsheets in Collate when they are removed from the source. Associated entities like worksheets and lineage are also deleted. |
     | Mark Deleted Worksheets | On | Soft-delete worksheets in Collate when they are removed from the source. Associated entities like lineage are also deleted. |
     | Include Directories | On | Fetch directory metadata. Turn off to skip directories entirely. |
     | Include Files | On | Fetch file metadata. Turn off to skip files entirely. |
     | Include Spreadsheets | On | Fetch spreadsheet metadata. Turn off to skip spreadsheets entirely. |
     | Include Worksheets | On | Fetch worksheet metadata. Turn off to skip worksheets entirely. |

     ![Agent Setup](https://mintcdn.com/collatedocs/tVR0kaoXvgs3p2Wx/public/images/ai-2.0/connectors/metadata-ingestion/Drive/drive-agent-setup.png?fit=max\&auto=format\&n=tVR0kaoXvgs3p2Wx\&q=85\&s=8a132a356d8ea3314299b648265a253c)

   * **Filter Patterns**: Apply include or exclude rules to scope which directories, files, spreadsheets, and worksheets this agent ingests. Use fully qualified name (FQN) filtering to apply a regular expression to fully qualified names (for example, `service_name.directory_name.file_name`) instead of raw names. These follow the same filter options described in **Step 5**.

     ![Filter Patterns](https://mintcdn.com/collatedocs/tVR0kaoXvgs3p2Wx/public/images/ai-2.0/connectors/metadata-ingestion/Drive/drive-filter-pattern.png?fit=max\&auto=format\&n=tVR0kaoXvgs3p2Wx\&q=85\&s=1337b9f82862926e08662b4f1fb0013b)

   * **Scope & Behaviour**: Control what metadata to include and how to handle deletions. Toggle each option on or off based on your needs:

     | Toggle | Default | Description |
     | - | - | - |
     | Enable Debug Log | Off | Sets the ingestion log level to DEBUG. Useful for troubleshooting. |
     | Include Tags | On | Ingest tags from the source. |
     | Include Owners | Off | Assign owners from the source when the owner email matches a Collate user. Does not overwrite an existing owner. |
     | Override Metadata | Off | When on, source values overwrite existing descriptions, tags, owners, and display names in Collate. A description or display name that the source doesn't send never replaces an existing value. If the connector supplies custom properties, the values it sends are merged over the existing ones: properties the source sends overwrite, and properties it doesn't send are kept. When off, Collate only updates fields that have no existing value. |

     ![Scope & Behaviour](https://mintcdn.com/collatedocs/tVR0kaoXvgs3p2Wx/public/images/ai-2.0/connectors/metadata-ingestion/Drive/drive-scope-behaviour.png?fit=max\&auto=format\&n=tVR0kaoXvgs3p2Wx\&q=85\&s=508c5978a32083dabbc5443f2a1ec4b4)

5. On the **Schedule Interval** page, set when the agent runs:

   * **Schedule**: Choose a preset interval (Hourly, Daily, Weekly, Monthly) or enter a custom cron expression.
   * **On-Demand**: No automatic schedule. Trigger the agent manually when needed.

   ![Schedule Interval](https://mintcdn.com/collatedocs/bv5oe4uRjuorTJO1/public/images/ai-2.0/connectors/metadata-ingestion/schedule.png?fit=max\&auto=format\&n=bv5oe4uRjuorTJO1\&q=85\&s=25cc1d78f6f2a8bd115830d034d1d8d1)

6. Click **Add** to deploy the agent.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.