Package: airbyte-source-microsoft-onedrive
Microsoft Onedrive SourceThis is the repository for the Microsoft Onedrive source connector, written in Python.
For information about how to use this connector within Airbyte, seethe documentation.To iterate on this connector, make sure to complete this prerequisites section.From this connector directory, create a virtual environment:python -m venv .venvThis will generate a virtualenv for this module in.venv/. Make sure this venv is active in your
development environment of choice. To activate it from the terminal, run:source .venv/bin/activate
pip install -r requirements.txt
pip install '.[tests]'If you are in an IDE, follow your IDE's instructions to activate the virtualenv.Note that while we are installing dependencies fromrequirements.txt, you should only editsetup.pyfor your dependencies.requirements.txtis
used for editable installs (pip install -e) to pull in Python dependencies from the monorepo and will callsetup.py.
If this is mumbo jumbo to you, don't worry about it, just put your deps insetup.pybut install usingpip install -r requirements.txtand everything
should work as you expect.If you are a community contributor, follow the instructions in thedocumentationto generate the necessary credentials. Then create a filesecrets/config.jsonconforming to thesource_microsoft_onedrive/spec.yamlfile.
Note that any directory namedsecretsis gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
Seeintegration_tests/sample_config.jsonfor a sample config file.If you are an Airbyte core member, copy the credentials in Lastpass under the secret namesource microsoft-onedrive test credsand place them intosecrets/config.json.python main.py spec
python main.py check --config secrets/config.json
python main.py discover --config secrets/config.json
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.jsonThe Airbyte way of building this connector is to use ourairbyte-citool.
You can follow install instructionshere.
Then running the following command will build your connector:airbyte-ciconnectors--namesource-microsoft-onedrivebuildOnce the command is done, you will find your connector image in your local docker registry:airbyte/source-microsoft-onedrive:dev.When contributing on our connector you might need to customize the build process to add a system dependency or set an env var.
You can customize our build process by adding abuild_customization.pymodule to your connector.
This module should contain apre_connector_installandpost_connector_installasync function that will mutate the base image and the connector container respectively.
It will be imported at runtime by our build process and the functions will be called if they exist.Here is an example of abuild_customization.pymodule:from__future__importannotationsfromtypingimportTYPE_CHECKINGifTYPE_CHECKING:fromdaggerimportContainerasyncdefpre_connector_install(base_image_container:Container)->Container:returnawaitbase_image_container.with_env_variable("MY_PRE_BUILD_ENV_VAR","my_pre_build_env_var_value")asyncdefpost_connector_install(connector_container:Container)->Container:returnawaitconnector_container.with_env_variable("MY_POST_BUILD_ENV_VAR","my_post_build_env_var_value")This connector is built using our dynamic built process inairbyte-ci.
The base image used to build it is defined within the metadata.yaml file under theconnectorBuildOptions.
The build logic is defined usingDaggerhere.
It does not rely on a Dockerfile.If you would like to patch our connector and build your own a simple approach would be to:Create your own Dockerfile based on the latest version of the connector image.FROMairbyte/source-microsoft-onedrive:latestCOPY../airbyte/integration_codeRUNpipinstall./airbyte/integration_codePlease use this as an example. This is not optimized.Build your image:dockerbuild-tairbyte/source-microsoft-onedrive:dev.
dockerrunairbyte/source-microsoft-onedrive:devspecThen run any of the connector commands as follows:docker run --rm airbyte/source-microsoft-onedrive:dev spec
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-microsoft-onedrive:dev check --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-microsoft-onedrive:dev discover --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-microsoft-onedrive:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.jsonMake sure to familiarize yourself withpytest test discoveryto know how your test files and methods should be named.
First install test dependencies into your virtual environment:pip install .[tests]To run unit tests locally, from the connector directory run:python -m pytest unit_testsThere are two types of integration tests: Acceptance Tests (Airbyte's test suite for all source connectors) and custom integration tests (which are specific to this connector).
Place custom tests insideintegration_tests/folder, then, from the connector root, runpython -m pytest integration_testsCustomizeacceptance-test-config.ymlfile to configure tests. SeeConnector Acceptance Testsfor more information.
If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.
Please run acceptance tests viaairbyte-ci:airbyte-ciconnectors--namesource-microsoft-onedrivetestAll of your dependencies should go insetup.py, NOTrequirements.txt. The requirements file is only used to connect internal Airbyte dependencies in the monorepo for local development.
We split dependencies between two groups, dependencies that are:required for your connector to work need to go toMAIN_REQUIREMENTSlist.required for the testing need to go toTEST_REQUIREMENTSlistYou've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?Make sure your changes are passing our test suite:airbyte-ci connectors --name=source-microsoft-onedrive testBump the connector version inmetadata.yaml: increment thedockerImageTagvalue. Please followsemantic versioning for connectors.Make sure themetadata.yamlcontent is up to date.Make the connector documentation and its changelog is up to date (docs/integrations/sources/microsoft-onedrive.md).Create a Pull Request: useour PR naming conventions.Pat yourself on the back for being an awesome contributor.Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.