Skip to content
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

Conversation

eugene-kulak
Copy link
Contributor

@eugene-kulak eugene-kulak commented Dec 24, 2020

Contributor Checklist

Thanks for contributing to Airbyte! Please complete the following items in order so we can review your PR.

  • Followed all the instructions in the locally generated checklist and your connector is functional & ready for review
  • Ran the standard test suite locally via ./gradlew :airbyte-integrations:connectors:source-<your_source_name>:standardSourceTestPython and pasted the summarized output as a comment in this PR

Reviewer Pre-merge Checklist

  • Finished iterating with the PR author on the code*
  • Created a branch off master to merge this PR into*
  • Inject the credentials in CI via ./tools/integrations/ci_credentials.sh and .github/workflows/test-command.yml*
  • Added the credentials for this integration to Github secrets
  • Run standard tests on this branch by commenting /test connector=<name>*
  • Add entry in airbyte-config/init/src/main/resources/seed/source_definitions.yaml to use the new source in Airbyte core
  • Deployed the connector to Dockerhub via ./tools/integrations/manage.sh publish airbyte-integrations/connectors/source-<name>

Documentation

  • Add docs in docs/integrations/sources/ folder in line with the documentation template found in docs/contributing-to-airbyte/templates/integration-documentation-template.md.
  • Add link to create docs file to docs/SUMMARY.md
  • Include a link to the documentation in the README.md


@staticmethod
def _find_account(account_id: str):
accounts = fb_user.User(fbid='me').get_ad_accounts()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about next to emulate find if?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please give me some example?
I think the current version is not too difficult to read, but maybe I'm wrong...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current code is OK to read, agree. I was thinking about:
return next((x for x in accounts if x["account_id"] == account_id),)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, I like this magic, but not in the code :)


def read_stream(self, stream: AirbyteStream) -> Generator[AirbyteRecordMessage, None, None]:
"""Yield records from stream"""
method = self._stream_methods.get(stream.name)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider moving this to the base class.
method = self.get_method(stream.name) would be more concise and expressive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to base class, and fixed existing derived classes to accept kwargs

print(stream.json_schema)
return []

def read_stream(self, stream: AirbyteStream) -> Generator[AirbyteRecordMessage, None, None]:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you override base class method? Looks like the implementation is identical.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to pass fields, please see my updates

@eugene-kulak
Copy link
Contributor Author

Test run finished after 36085 ms
[         2 containers found      ]
[         0 containers skipped    ]
[         2 containers started    ]
[         0 containers aborted    ]
[         2 containers successful ]
[         0 containers failed     ]
[         7 tests found           ]
[         0 tests skipped         ]
[         7 tests started         ]
[         0 tests aborted         ]
[         7 tests successful      ]
[         0 tests failed          ]

@eugene-kulak eugene-kulak changed the title WIP: Source Facebook Marketing (no-singer) Source Facebook Marketing (no-singer) Dec 29, 2020
Copy link
Contributor

@jrhizor jrhizor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generally looks good. Just a few minor comments for now.

I'm going to run some tests on this later tonight or tomorrow morning.

name: Facebook Marketing
dockerRepository: airbyte/source-facebook-marketing
dockerImageTag: 0.1.0
documentationUrl: https://hub.docker.com/r/airbyte/source-facebook-marketing
- sourceDefinitionId: 74d47f79-8d01-44ac-9755-f5eb0d7caacb
name: Facebook Marketing APIs
Copy link
Contributor

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.

docs/integrations/sources/facebook-marketing.md Outdated Show resolved Hide resolved
@@ -0,0 +1,7 @@
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this file be in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted


fields = list(set(fields) - set(self.INVALID_INSIGHT_FIELDS))

# Some automatic fields (primary-keys) cannot be used as 'fields' query params.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be moved to where INVALID_INSIGHT_FIELDS is defined.

eugene-kulak and others added 4 commits December 30, 2020 05:47
…d.gradle

Co-authored-by: Jared Rhizor <me@jaredrhizor.com>
Co-authored-by: Jared Rhizor <me@jaredrhizor.com>
…_tests/test_client.py

Co-authored-by: Jared Rhizor <me@jaredrhizor.com>
Copy link
Contributor

@jrhizor jrhizor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The integration tests are working and everything looks good, but there are errors when I run the unit tests with ./gradlew :airbyte-integrations:connectors:source-facebook-marketing:unitTest from the airbyte root directory or .venv/bin/python -m pytest unit_tests from the source's directory.

Messages must be strings for AirbyteLogMessage.

This is the only issue blocking this PR.

@eugene-kulak
Copy link
Contributor Author

@jrhizor thanks, I have fixed logger usage in the last commit

@jrhizor
Copy link
Contributor

jrhizor commented Dec 31, 2020

You'll also have to run ./gradlew format to format the JSON files added in the PR.

@jrhizor
Copy link
Contributor

jrhizor commented Jan 5, 2021

I'm running the build again from #1525

Please look into build failures if there are any. If it succeeds I'll merge this.

Sorry for the delay.

@jrhizor
Copy link
Contributor

jrhizor commented Jan 5, 2021

It looks like the changes here introduced a dependency issue as well.

It's really slow for me to create a separate PR and wait for builds to iterate with feedback. Can you reopen this PR on an origin branch instead of a fork so the builds can run automatically? Then you can iterate until the build is passing without any involvement from me, and it will be obvious when this is ready to merge.

Here's a failing build run: https://github.com/airbytehq/airbyte/runs/1651989807

Alternatively, you could ping me on this PR once ./gradlew build is passing locally.

@eugene-kulak
Copy link
Contributor Author

closed in favor of #1552

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants