name: migrate-legacy-implementation description: Migrate a legacy source connector from the old sources/ directory to the new package structure under src/databricks/labs/community_connector/sources/. disable-model-invocation: true
Migrate Legacy Source Implementation
Description
This skill migrates an old connector implementation from the legacy sources/ directory to the new package structure under src/databricks/labs/community_connector/sources/. It handles one specified source at a time, updating imports, conforming to the LakeflowConnect interface, and regenerating specs and build files.
Instructions
Handle one specified source at a time. Refer other source (e.g. example) as a reference. Use python3.10 to replace all python command. When running any python test or build use virtual environment (Python 3.10+ required), run these: python3.10 -m venv .venv source .venv/bin/activate python -m pip install -e ".[dev]" then run other python commands or pytest.
Steps
Run shell command to
git mvthe files for the specified source undersources/to the new directory. Commit the change.- Files under
sources/{source_name}/tests/need to move totests/unit/sources/{source_name} sources/{source_name}/configsneeds to move totests/unit/sources/{source_name}as well
- Files under
Update
{source_name}.py:- Import the
LakeflowConnectinterface fromsrc/databricks/labs/community_connector/interface/lakeflow_connect.pyand change the existingLakeflowConnectclass to implement the interface with name{SourceName}LakeflowConnect.
- Import the
Update import paths in all moved files and expose
{SourceName}LakeflowConnectin__init__.pyunder{source_name}to make it available in the package.- libs are moved from root directory to src/databricks/labs/community_connector/libs, so you can use the same library functions.
- Also update the test imports and code if necessary.
- Commit the changes so far.
If
{source_name}.pyis too large (>1000 lines), consider refactoring it into multiple files. One example to follow isexample.Run the tests — they will fail but should not be syntax or import errors.
- Add the unit test that requires credentials (the one built on top of the source test_suite) to .github/workflows/test_exclude.txt
- Commit the changes so far.
Update the
README.mdunder{source_name}directory to make sure all references and content match the latest changes.Use the
generate-connector-specskill to regenerate the spec for this connector.Use the
build_connector_packageskill to build thepyproject.tomland related files.- Commit the changes so far.
If there are any .py files that should not be imported as part of {source_name}.py, exclude them in the tools/scripts/merge_exclude_config.json
You should change any other directories other than src/databricks/labs/community_connector/sources/{source_name} directory. Delete other directories like libs, pipeline under root.
- Commit all the changes.
run tools/scripts/merge_python_source.py to create _generated source code.
- Commit the the changes.