-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
4,425 additions
and
8 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
from pipelines.ocr_radar.dump_db_radar.flows import * # noqa: F401, F403 |
Empty file.
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,45 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Database dumping flows for cetrio project. | ||
""" | ||
|
||
from copy import deepcopy | ||
|
||
from prefect.run_configs import KubernetesRun | ||
from prefect.storage import GCS | ||
from prefeitura_rio.pipelines_templates.dump_db.flows import flow as dump_sql_flow | ||
from prefeitura_rio.pipelines_utils.prefect import set_default_parameters | ||
from prefeitura_rio.pipelines_utils.state_handlers import ( | ||
handler_initialize_sentry, | ||
handler_inject_bd_credentials, | ||
) | ||
|
||
from pipelines.constants import constants | ||
from pipelines.ocr_radar.dump_db_radar.schedules import ( | ||
ocr_radar_monthly_update_schedule, | ||
) | ||
|
||
dump_sql_ocr_radar_flow = deepcopy(dump_sql_flow) | ||
dump_sql_ocr_radar_flow.state_handlers = [handler_inject_bd_credentials, handler_initialize_sentry] | ||
dump_sql_ocr_radar_flow.name = "CETRIO: ocr radar - Ingerir tabelas de banco SQL" | ||
dump_sql_ocr_radar_flow.storage = GCS(constants.GCS_FLOWS_BUCKET.value) | ||
dump_sql_ocr_radar_flow.run_config = KubernetesRun( | ||
image=constants.DOCKER_IMAGE.value, | ||
labels=[ | ||
constants.RJ_CETRIO_AGENT_LABEL.value, | ||
], | ||
) | ||
|
||
ocr_radar_default_parameters = { | ||
"db_database": "DWOCR_Staging", | ||
"db_host": "10.39.64.50", | ||
"db_port": "1433", | ||
"db_type": "sql_server", | ||
"infisical_secret_path": "/db-ocr-radar", | ||
"dataset_id": "recursos_humanos_ocr_radar", | ||
} | ||
dump_sql_ocr_radar_flow = set_default_parameters( | ||
dump_sql_ocr_radar_flow, default_parameters=ocr_radar_default_parameters | ||
) | ||
|
||
dump_sql_ocr_radar_flow.schedule = ocr_radar_monthly_update_schedule |
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,51 @@ | ||
# -*- coding: utf-8 -*- | ||
# flake8: noqa: E501 | ||
""" | ||
Schedules for the database dump pipeline | ||
""" | ||
|
||
from datetime import datetime, timedelta | ||
|
||
import pytz | ||
from prefect.schedules import Schedule | ||
from prefeitura_rio.pipelines_utils.io import untuple_clocks as untuple | ||
from prefeitura_rio.pipelines_utils.prefect import generate_dump_db_schedules | ||
|
||
from pipelines.constants import constants | ||
|
||
##################################### | ||
# | ||
# ocr_radar Schedules | ||
# | ||
##################################### | ||
|
||
ocr_radar_queries = { | ||
"equipamento": { | ||
"materialize_after_dump": True, | ||
"biglake_table": True, | ||
"materialization_mode": "prod", | ||
"dump_mode": "overwrite", | ||
"execute_query": """ | ||
SELECT | ||
* | ||
FROM [DBOCR_2024].[dbo].[Equipamento] | ||
""", | ||
}, | ||
} | ||
|
||
ocr_radar_clocks = generate_dump_db_schedules( | ||
interval=timedelta(days=100), | ||
start_date=datetime(2022, 11, 9, 22, 30, tzinfo=pytz.timezone("America/Sao_Paulo")), | ||
labels=[ | ||
constants.RJ_CETRIO_AGENT_LABEL.value, | ||
], | ||
db_database="DBOCR_2024", | ||
db_host="10.39.64.50", | ||
db_port="1433", | ||
db_type="sql_server", | ||
dataset_id="ocr_radar", | ||
infisical_secret_path="/db-ocr-radar", | ||
table_parameters=ocr_radar_queries, | ||
) | ||
|
||
ocr_radar_monthly_update_schedule = Schedule(clocks=untuple(ocr_radar_clocks)) |
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,2 @@ | ||
# -*- coding: utf-8 -*- | ||
from pipelines.templates.run_dbt_model.flows import * # noqa: F401, F403 |
Empty file.
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,36 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
MATERIALIZA MODELOS DO DBT. | ||
""" | ||
|
||
from copy import deepcopy | ||
|
||
from prefect.run_configs import KubernetesRun | ||
from prefect.storage import GCS | ||
from prefeitura_rio.pipelines_templates.run_dbt_model.flows import ( | ||
templates__run_dbt_model__flow, | ||
) | ||
from prefeitura_rio.pipelines_utils.prefect import set_default_parameters | ||
from prefeitura_rio.pipelines_utils.state_handlers import handler_inject_bd_credentials | ||
|
||
from pipelines.constants import constants | ||
|
||
templates__run_dbt_model_smas__flow = deepcopy(templates__run_dbt_model__flow) | ||
templates__run_dbt_model_smas__flow.state_handlers = [handler_inject_bd_credentials] | ||
|
||
templates__run_dbt_model_smas__flow.storage = GCS(constants.GCS_FLOWS_BUCKET.value) | ||
templates__run_dbt_model_smas__flow.run_config = KubernetesRun( | ||
image=constants.DOCKER_IMAGE.value, | ||
labels=[ | ||
constants.RJ_CETRIO_AGENT_LABEL.value, | ||
], | ||
) | ||
|
||
templates_run_dbt_model_smas_default_parameters = { | ||
"dataset_id": "dataset_id", | ||
"table_id": "table_id", | ||
} | ||
templates__run_dbt_model_smas__flow = set_default_parameters( | ||
templates__run_dbt_model_smas__flow, | ||
default_parameters=templates_run_dbt_model_smas_default_parameters, | ||
) |
Oops, something went wrong.