-
Notifications
You must be signed in to change notification settings - Fork 6
feat: JBDA import #1407
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
Merged
Merged
feat: JBDA import #1407
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3d93645
feat: jbda import
cka-y b1dc6a7
merge: main
cka-y 9124cc5
merge: main
cka-y 8d331bf
fix: tests
cka-y d9f02c5
fix: trigger dataset download
cka-y bb321ee
fix: var name
cka-y 44d2ded
fix: downstream tasks tested
cka-y c576fe8
fix: missing schedule
cka-y 6fc3950
fix scheduler payload
cka-y dd0c372
pr comments
cka-y d1e9afe
merge: main
cka-y c1e4bbd
functionnal code
cka-y 49f6c9d
fix: pr comment
cka-y a5db774
fix: pr comments
cka-y e6bd3c0
fix: ts types
cka-y f0c970e
Merge branch 'main' into feat/pt-154
cka-y 1236542
fix: operation api model
cka-y a100ffc
fix: missing timestamp
cka-y 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
| from feeds_gen.models.feed_related_link import FeedRelatedLink | ||
| from shared.database_gen.sqlacodegen_models import Feedrelatedlink | ||
|
|
||
|
|
||
| class FeedRelatedLinkImpl(FeedRelatedLink): | ||
| """Implementation of the FeedRelatedLink model.""" | ||
|
|
||
| class Config: | ||
| """Pydantic configuration. | ||
| Enabling `from_orm` method to create a model instance from a SQLAlchemy row object.""" | ||
|
|
||
| from_attributes = True | ||
|
|
||
| @classmethod | ||
| def from_orm(cls, feed_related_link_orm: Feedrelatedlink) -> FeedRelatedLink | None: | ||
| if not feed_related_link_orm: | ||
| return None | ||
| return cls( | ||
| code=feed_related_link_orm.code, | ||
| url=feed_related_link_orm.url, | ||
| description=feed_related_link_orm.description, | ||
| created_at=feed_related_link_orm.created_at, | ||
| ) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -27,3 +27,4 @@ google-cloud-storage | |
|
|
||
| # Configuration | ||
| python-dotenv==1.0.0 | ||
| pycountry | ||
This file contains hidden or 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
43 changes: 43 additions & 0 deletions
43
functions-python/tasks_executor/src/tasks/data_import/data_import_utils.py
This file contains hidden or 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,43 @@ | ||
| import os | ||
| from shared.database_gen.sqlacodegen_models import Feed | ||
| import logging | ||
| import json | ||
| from google.cloud import pubsub_v1 | ||
|
|
||
| PROJECT_ID = os.getenv("PROJECT_ID") | ||
| DATASET_BATCH_TOPIC = os.getenv("DATASET_PROCESSING_TOPIC_NAME") | ||
|
|
||
|
|
||
| def trigger_dataset_download( | ||
| feed: Feed, execution_id: str, publisher: pubsub_v1.PublisherClient | ||
| ) -> None: | ||
| """Publishes the feed to the configured Pub/Sub topic.""" | ||
| topic_path = publisher.topic_path(PROJECT_ID, DATASET_BATCH_TOPIC) | ||
| logging.debug("Publishing to Pub/Sub topic: %s", topic_path) | ||
|
|
||
| message_data = { | ||
| "execution_id": execution_id, | ||
| "producer_url": feed.producer_url, | ||
| "feed_stable_id": feed.stable_id, | ||
| "feed_id": feed.id, | ||
| "dataset_id": None, | ||
| "dataset_hash": None, | ||
| "authentication_type": feed.authentication_type, | ||
| "authentication_info_url": feed.authentication_info_url, | ||
| "api_key_parameter_name": feed.api_key_parameter_name, | ||
| } | ||
|
|
||
| try: | ||
| # Convert to JSON string | ||
| json_message = json.dumps(message_data) | ||
| future = publisher.publish(topic_path, data=json_message.encode("utf-8")) | ||
| future.add_done_callback( | ||
| lambda _: logging.info( | ||
| "Published feed %s to dataset batch topic", feed.stable_id | ||
| ) | ||
| ) | ||
| future.result() | ||
| logging.info("Message published for feed %s", feed.stable_id) | ||
| except Exception as e: | ||
| logging.error("Error publishing to dataset batch topic: %s", str(e)) | ||
| raise |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.