-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Source Facebook Marketing (no-singer) #1443
Closed
eugene-kulak
wants to merge
27
commits into
airbytehq:master
from
eugene-kulak:source-facebook-marketing
Closed
Changes from 18 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
dc5f72e
source Facebook Marketing (no-singer)
eugene-kulak 9cef6e3
update sample config
eugene-kulak bd81d25
fix source import
eugene-kulak 17884b2
add fixme
eugene-kulak 0f7e9c9
fix tests, account fetch and stream reading
eugene-kulak 6343bfc
implement schema resolver
eugene-kulak b59d50d
add CI creds
eugene-kulak a422faf
register as standard source
eugene-kulak 7a21b16
fix tests
eugene-kulak 0b5d914
format
eugene-kulak 1ff5878
fix Dockerfile.test
eugene-kulak c909a4b
fix python3.7 compatibility
eugene-kulak 555038e
clean up
eugene-kulak 5530fa7
address comments from @arhip11
eugene-kulak a842673
address comments from @arhip11
eugene-kulak ced47e8
Merge remote-tracking branch 'origin/master' into source-facebook-mar…
eugene-kulak e285d71
clean up
eugene-kulak c99e121
"fix" logger usage, better fix possible in #1279
eugene-kulak 3731637
fix incorrect logger usage
eugene-kulak 14c9086
fix incorrect logger usage (2)
eugene-kulak 19b2de3
Update airbyte-integrations/connectors/source-facebook-marketing/buil…
eugene-kulak 929d2ac
Update docs/integrations/sources/facebook-marketing.md
eugene-kulak 79a33f3
Update airbyte-integrations/connectors/source-facebook-marketing/unit…
eugene-kulak 0d1017b
address CR changes
eugene-kulak 54b1953
drop accidentally added .dockerinore file
eugene-kulak dee3d88
fix logger usage (3)
eugene-kulak 13c2eee
format
eugene-kulak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...ain/resources/config/STANDARD_SOURCE_DEFINITION/e7778cfc-e97c-4458-9ecb-b4f2bba8946c.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"sourceDefinitionId": "e7778cfc-e97c-4458-9ecb-b4f2bba8946c", | ||
"name": "Facebook Marketing", | ||
"dockerRepository": "airbyte/source-facebook-marketing", | ||
"dockerImageTag": "0.1.0", | ||
"documentationUrl": "https://hub.docker.com/r/airbyte/source-facebook-marketing" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
airbyte-integrations/connectors/source-facebook-marketing/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM airbyte/integration-base-python:dev | ||
|
||
# Bash is installed for more convenient debugging. | ||
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/* | ||
|
||
ENV CODE_PATH="source_facebook_marketing" | ||
ENV AIRBYTE_IMPL_MODULE="source_facebook_marketing" | ||
ENV AIRBYTE_IMPL_PATH="SourceFacebookMarketing" | ||
|
||
WORKDIR /airbyte/integration_code | ||
COPY $CODE_PATH ./$CODE_PATH | ||
COPY setup.py ./ | ||
RUN pip install . | ||
|
||
LABEL io.airbyte.version=0.1.0 | ||
LABEL io.airbyte.name=airbyte/source-facebook-marketing |
22 changes: 22 additions & 0 deletions
22
airbyte-integrations/connectors/source-facebook-marketing/Dockerfile.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM airbyte/base-python-test:dev | ||
|
||
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/* | ||
|
||
ENV CODE_PATH="integration_tests" | ||
ENV AIRBYTE_TEST_MODULE="integration_tests" | ||
ENV AIRBYTE_TEST_PATH="SourceFacebookMarketingStandardTest" | ||
|
||
LABEL io.airbyte.version=0.1.0 | ||
LABEL io.airbyte.name=airbyte/source-facebook-marketing-standard-test | ||
|
||
WORKDIR /airbyte/integration_code | ||
COPY source_facebook_marketing source_facebook_marketing | ||
COPY $CODE_PATH $CODE_PATH | ||
COPY sample_files/*.json $CODE_PATH/ | ||
COPY secrets/* $CODE_PATH | ||
COPY source_facebook_marketing/*.json $CODE_PATH | ||
COPY setup.py ./ | ||
|
||
RUN pip install ".[tests]" | ||
|
||
WORKDIR /airbyte |
73 changes: 73 additions & 0 deletions
73
airbyte-integrations/connectors/source-facebook-marketing/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Facebook Marketing Source | ||
|
||
This is the repository for the Facebook Marketing source connector, written in Python. | ||
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/facebook-marketing). | ||
|
||
## Local development | ||
|
||
### Prerequisites | ||
**To iterate on this connector, make sure to complete this prerequisites section.** | ||
|
||
#### Build & Activate Virtual Environment | ||
First, build the module by running the following from the `airbyte` project root directory: | ||
``` | ||
./gradlew :airbyte-integrations:connectors:source-facebook-marketing:build | ||
``` | ||
|
||
This will generate a virtualenv for this module in `source-facebook-marketing/.venv`. Make sure this venv is active in your | ||
development environment of choice. To activate the venv from the terminal, run: | ||
``` | ||
cd airbyte-integrations/connectors/source-facebook-marketing # cd into the connector directory | ||
source .venv/bin/activate | ||
``` | ||
If you are in an IDE, follow your IDE's instructions to activate the virtualenv. | ||
|
||
#### Create credentials | ||
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/facebook-marketing) | ||
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_facebook_marketing/spec.json` file. | ||
See `sample_files/sample_config.json` for a sample config file. | ||
|
||
**If you are an Airbyte core member**, copy the credentials in RPass under the secret name `source-facebook-marketing-integration-test-config` | ||
and place them into `secrets/config.json`. | ||
|
||
|
||
### Locally running the connector | ||
``` | ||
python main_dev.py spec | ||
python main_dev.py check --config secrets/config.json | ||
python main_dev.py discover --config secrets/config.json | ||
python main_dev.py read --config secrets/config.json --catalog sample_files/configured_catalog.json | ||
``` | ||
|
||
### Unit Tests | ||
To run unit tests locally, from the connector directory run: | ||
``` | ||
pytest unit_tests | ||
``` | ||
|
||
### Locally running the connector docker image | ||
``` | ||
# in airbyte root directory | ||
./gradlew :airbyte-integrations:connectors:source-facebook-marketing:airbyteDocker | ||
docker run --rm airbyte/source-facebook-marketing:dev spec | ||
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-facebook-marketing/secrets:/secrets airbyte/source-facebook-marketing:dev check --config /secrets/config.json | ||
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-facebook-marketing/secrets:/secrets airbyte/source-facebook-marketing:dev discover --config /secrets/config.json | ||
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-facebook-marketing/secrets:/secrets -v $(pwd)/airbyte-integrations/connectors/source-facebook-marketing/sample_files:/sample_files airbyte/source-facebook-marketing:dev read --config /secrets/config.json --catalog /sample_files/configured_catalog.json | ||
``` | ||
|
||
### Integration Tests | ||
1. From the airbyte project root, run `./gradlew :airbyte-integrations:connectors:source-facebook-marketing:standardSourceTestPython` to run the standard integration test suite. | ||
1. To run additional integration tests, place your integration tests in the `integration_tests` directory and run them with `pytest integration_tests`. | ||
Make sure to familiarize yourself with [pytest test discovery](https://docs.pytest.org/en/latest/goodpractices.html#test-discovery) to know how your test files and methods should be named. | ||
|
||
## Dependency Management | ||
All of your dependencies should go in `setup.py`, NOT `requirements.txt`. The requirements file is only used to connect internal Airbyte dependencies in the monorepo for local development. | ||
|
||
## Populating account with the data | ||
|
||
The following will create 120 accounts and conversations | ||
```bash | ||
export DRIFT_TOKEN=<PUT_YOUR_TOKEN_HERE> | ||
cd airbyte-integrations/connectors/source-facebook-marketing/source_facebook_marketing/ | ||
python -m client.fixture | ||
``` |
14 changes: 14 additions & 0 deletions
14
airbyte-integrations/connectors/source-facebook-marketing/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
plugins { | ||
id 'airbyte-python' | ||
id 'airbyte-docker' | ||
id 'airbyte-source-test' | ||
id 'airbyte-integration-test-java' | ||
eugene-kulak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
airbytePython { | ||
moduleDirectory 'source_facebook_marketing' | ||
} | ||
|
||
dependencies { | ||
implementation files(project(':airbyte-integrations:bases:base-python').airbyteDocker.outputs) | ||
} |
27 changes: 27 additions & 0 deletions
27
airbyte-integrations/connectors/source-facebook-marketing/integration_tests/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
MIT License | ||
|
||
Copyright (c) 2020 Airbyte | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
""" | ||
|
||
from .standard_source_test import SourceFacebookMarketingStandardTest | ||
|
||
__all__ = ["SourceFacebookMarketingStandardTest"] |
29 changes: 29 additions & 0 deletions
29
...tegrations/connectors/source-facebook-marketing/integration_tests/standard_source_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
MIT License | ||
|
||
Copyright (c) 2020 Airbyte | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
""" | ||
|
||
from base_python_test import DefaultStandardSourceTest | ||
|
||
|
||
class SourceFacebookMarketingStandardTest(DefaultStandardSourceTest): | ||
pass |
32 changes: 32 additions & 0 deletions
32
airbyte-integrations/connectors/source-facebook-marketing/main_dev.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
MIT License | ||
|
||
Copyright (c) 2020 Airbyte | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
""" | ||
|
||
import sys | ||
|
||
from base_python.entrypoint import launch | ||
from source_facebook_marketing import SourceFacebookMarketing | ||
|
||
if __name__ == "__main__": | ||
source = SourceFacebookMarketing() | ||
launch(source, sys.argv[1:]) |
4 changes: 4 additions & 0 deletions
4
airbyte-integrations/connectors/source-facebook-marketing/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-e ../../bases/airbyte-protocol | ||
-e ../../bases/base-python | ||
-e ../../bases/base-python-test | ||
-e . |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a separate PR we should delete the Singer one.