> ## Documentation Index
> Fetch the complete documentation index at: https://openmetadata-format-2-0-connector-overview-pages.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Drive Connector | Build & Extend OpenMetadata Easily

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

# Custom Drive Connector

Just like other services in OpenMetadata (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 OpenMetadata.

In this guide, we'll walk 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>
  Review the [tested Custom Drive source](https://github.com/open-metadata/OpenMetadata/blob/main/ingestion/tests/integration/custom_connectors/custom_drive.py) for a complete source implementation.
</Tip>

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

<iframe width="800" height="450" src="https://www.youtube.com/embed/fDUj30Ub9VE" title="YouTube video player" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />

## Steps to Set Up a Custom Drive Connector

Follow these steps to build and register 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.
</Tip>

For more on the ingestion framework, refer to the [OpenMetadata Ingestion Workflow docs](/v2.0.x-SNAPSHOT/connectors/ingestion/workflows).

### 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:<version>

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 OpenMetadata version that is running your server/UI.

### Step 5 - Run OpenMetadata 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 and Run the Connector

The Custom Drive service form does not expose a Source Python Class field. Add the fully qualified class name to your ingestion YAML, then run it with the ingestion CLI.

```yaml theme={null}
source:
  type: custom-drive
  serviceName: <service_name>
  serviceConnection:
    config:
      type: CustomDrive
      sourcePythonClass: custom_drive.my_drive_connector.MyDriveConnector
  sourceConfig:
    config:
      type: DriveMetadata
sink:
  type: metadata-rest
  config: {}
```

Run `metadata ingest -c <path-to-config.yaml>`.

## Configure Metadata Agent and Schedule Ingestion

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

When you click **Create & Deploy**, OpenMetadata 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 service type.

   <img src="https://mintcdn.com/openmetadata-format-2-0-connector-overview-pages/aexFmzYHE_P6Lrks/public/images/connector2.0/metadata-ingestion/access-service-type.png?fit=max&auto=format&n=aexFmzYHE_P6Lrks&q=85&s=3c2d6613c061c17412ec5c800c0f3833" alt="Navigate to Settings and Services" width="2992" height="1612" data-path="public/images/connector2.0/metadata-ingestion/access-service-type.png" />

2. Click the service you have added.

3. Select the **Agents** tab and click **Add Agent** > **Metadata**.

   <img src="https://mintcdn.com/openmetadata-format-2-0-connector-overview-pages/aexFmzYHE_P6Lrks/public/images/connector2.0/metadata-ingestion/add-metadata-agent.png?fit=max&auto=format&n=aexFmzYHE_P6Lrks&q=85&s=9a59a29bca844f3035d14a7211574c57" alt="Add Metadata Agent" width="2398" height="1144" data-path="public/images/connector2.0/metadata-ingestion/add-metadata-agent.png" />

   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.

     <img src="https://mintcdn.com/openmetadata-format-2-0-connector-overview-pages/aexFmzYHE_P6Lrks/public/images/connector2.0/metadata-ingestion/metadata-agent-name.png?fit=max&auto=format&n=aexFmzYHE_P6Lrks&q=85&s=fa31ef8cb17d501983dd958c19e0c414" alt="Name this Ingestion" width="1578" height="644" data-path="public/images/connector2.0/metadata-ingestion/metadata-agent-name.png" />

   * **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 OpenMetadata 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 OpenMetadata when they are removed from the source. Associated entities like lineage are also deleted.                                            |
     | Mark Deleted Spreadsheets | On      | Soft-delete spreadsheets in OpenMetadata when they are removed from the source. Associated entities like worksheets and lineage are also deleted.                      |
     | Mark Deleted Worksheets   | On      | Soft-delete worksheets in OpenMetadata 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.                                                                                                        |

     <img src="https://mintcdn.com/openmetadata-format-2-0-connector-overview-pages/gRbSGI6PilrVY_cm/public/images/connector2.0/metadata-ingestion/Drive/drive-agent-setup.png?fit=max&auto=format&n=gRbSGI6PilrVY_cm&q=85&s=e38a68955a3030beab61fd307dfd552d" alt="Agent Setup" width="1530" height="1558" data-path="public/images/connector2.0/metadata-ingestion/Drive/drive-agent-setup.png" />

   * **Filter Patterns**: Apply include or exclude rules to scope which directories, files, spreadsheets, and worksheets this agent ingests. Use FQN for filtering to apply regex on 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: Configure Ingestion Options**.

     <img src="https://mintcdn.com/openmetadata-format-2-0-connector-overview-pages/gRbSGI6PilrVY_cm/public/images/connector2.0/metadata-ingestion/Drive/drive-filter-pattern.png?fit=max&auto=format&n=gRbSGI6PilrVY_cm&q=85&s=38048f510fb971d86114fd6989d26a24" alt="Filter Patterns" width="1570" height="1040" data-path="public/images/connector2.0/metadata-ingestion/Drive/drive-filter-pattern.png" />

   * **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 an OpenMetadata user. Does not overwrite an existing owner.                                                           |
     | Override Metadata | Off     | When on, source values overwrite existing descriptions, tags, owners, and display names in OpenMetadata. When off, OpenMetadata only updates fields that have no existing value. |

     <img src="https://mintcdn.com/openmetadata-format-2-0-connector-overview-pages/gRbSGI6PilrVY_cm/public/images/connector2.0/metadata-ingestion/Drive/drive-scope-behaviour.png?fit=max&auto=format&n=gRbSGI6PilrVY_cm&q=85&s=e29be1c2cc32fd1bd4df0af73f97fb1a" alt="Scope & Behaviour" width="1562" height="894" data-path="public/images/connector2.0/metadata-ingestion/Drive/drive-scope-behaviour.png" />

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.

   <img src="https://mintcdn.com/openmetadata-format-2-0-connector-overview-pages/wI1VkO40X1vdRc0T/public/images/connectors/schedule.png?fit=max&auto=format&n=wI1VkO40X1vdRc0T&q=85&s=14df1dfeef735efd1ad9fb45da8a7352" alt="Schedule Interval" width="2733" height="1083" data-path="public/images/connectors/schedule.png" />

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