@dataif/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/bin/dataif.js +623 -0
- package/package.json +26 -0
- package/scripts/build-template.mjs +72 -0
- package/templates/dataif/README.md +157 -0
- package/templates/dataif/infra/.env.example +119 -0
- package/templates/dataif/infra/.env.stg.example +119 -0
- package/templates/dataif/infra/airflow/Dockerfile +11 -0
- package/templates/dataif/infra/airflow/Dockerfile.release +17 -0
- package/templates/dataif/infra/airflow/requirements.txt +3 -0
- package/templates/dataif/infra/docker-compose.yml +306 -0
- package/templates/dataif/infra/init-db/01-init-dataif.sh +129 -0
- package/templates/dataif/infra/init-db/pnp-curated-views.sqlinc +444 -0
- package/templates/dataif/infra/init-db/pnp-raw-staging-curated.sqlinc +701 -0
- package/templates/dataif/infra/keycloak/Dockerfile +4 -0
- package/templates/dataif/infra/keycloak/realm-dataif.json +73 -0
- package/templates/dataif/infra/ollama/Dockerfile +9 -0
- package/templates/dataif/infra/ollama/bootstrap-model.sh +100 -0
- package/templates/dataif/infra/ollama/sabia-7b.Modelfile +14 -0
- package/templates/dataif/infra/postgres/Dockerfile +4 -0
- package/templates/dataif/pipelines/airflow/dags/generated/.gitkeep +1 -0
- package/templates/dataif/pipelines/airflow/dags/generated/2020_financeiro_fcc6f1f3_sync.py +9 -0
- package/templates/dataif/pipelines/dataif_pipelines/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/airflow/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/airflow/pnp_pipeline_factory.py +167 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/base/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/base/connector.py +28 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/base/types.py +14 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/nilo_pecanha/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/nilo_pecanha/config.py +19 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/nilo_pecanha/connector.py +558 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/nilo_pecanha/powerbi_microdados.py +728 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/nilo_pecanha/transform.py +296 -0
- package/templates/dataif/pipelines/dataif_pipelines/jobs/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/jobs/nilo_pipeline.py +112 -0
- package/templates/dataif/pipelines/dataif_pipelines/orchestration/__init__.py +21 -0
- package/templates/dataif/pipelines/dataif_pipelines/orchestration/pnp_workflow.py +783 -0
- package/templates/dataif/pipelines/dataif_pipelines/repositories/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/repositories/pnp_raw_repository.py +860 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/__init__.py +19 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/pnp_curated_service.py +66 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/pnp_download_service.py +534 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/pnp_quality_service.py +9 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/pnp_raw_ingestion_service.py +124 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/pnp_staging_service.py +271 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/powerbi_catalog_service.py +159 -0
- package/templates/dataif/pipelines/sql/staging/020_pnp_matriculas.sql +112 -0
- package/templates/dataif/pipelines/sql/staging/030_pnp_eficiencia_academica.sql +83 -0
- package/templates/dataif/pipelines/sql/staging/040_pnp_servidores.sql +90 -0
- package/templates/dataif/pipelines/sql/staging/050_pnp_financeiro.sql +72 -0
- package/templates/dataif/pipelines/sql/views_curated/004_mv_pnp_dashboard_fast.sql +204 -0
- package/templates/dataif/pipelines/sql/views_curated/010_vw_pnp_admin_ingestao.sql +51 -0
- package/templates/dataif/pipelines/sql/views_curated/020_vw_pnp_qualidade_dados.sql +114 -0
- package/templates/dataif/pipelines/sql/views_curated/030_vw_pnp_matriculas.sql +67 -0
- package/templates/dataif/pipelines/sql/views_curated/040_vw_pnp_eficiencia.sql +33 -0
- package/templates/dataif/pipelines/sql/views_curated/050_vw_pnp_servidores.sql +30 -0
- package/templates/dataif/pipelines/sql/views_curated/060_vw_pnp_financeiro.sql +22 -0
- package/templates/dataif/pipelines/sql/views_curated/070_vw_pnp_vanna.sql +115 -0
- package/templates/dataif/scripts/configure-env.sh +149 -0
- package/templates/dataif/scripts/create_metabase_pnp_dashboard.py +943 -0
- package/templates/dataif/scripts/create_metabase_pnp_matriculas_dashboard.py +580 -0
- package/templates/dataif/scripts/deploy.sh +79 -0
- package/templates/dataif/scripts/fix_metabase_template_tag_ids.py +91 -0
- package/templates/dataif/scripts/pnp_powerbi_microdados_probe.py +14 -0
- package/templates/dataif/scripts/pnp_validate_raw_run.py +330 -0
- package/templates/dataif/scripts/publish-images.sh +31 -0
- package/templates/dataif/scripts/sync_metabase_dashboard_field_filters.py +241 -0
- package/templates/dataif/scripts/use-vanna-ollama.sh +139 -0
- package/templates/dataif/services/api/.dockerignore +18 -0
- package/templates/dataif/services/api/Dockerfile +12 -0
- package/templates/dataif/services/api/app/__init__.py +1 -0
- package/templates/dataif/services/api/app/auth.py +48 -0
- package/templates/dataif/services/api/app/config.py +59 -0
- package/templates/dataif/services/api/app/keycloak_admin.py +215 -0
- package/templates/dataif/services/api/app/main.py +2432 -0
- package/templates/dataif/services/api/app/metabase_admin.py +191 -0
- package/templates/dataif/services/api/app/metabase_bootstrap.py +44 -0
- package/templates/dataif/services/api/app/metabase_embed.py +15 -0
- package/templates/dataif/services/api/app/pnp_dag_provisioner.py +113 -0
- package/templates/dataif/services/api/app/pnp_instance_repository.py +951 -0
- package/templates/dataif/services/api/app/pnp_powerbi.py +438 -0
- package/templates/dataif/services/api/app/vanna_client.py +32 -0
- package/templates/dataif/services/api/requirements.txt +9 -0
- package/templates/dataif/services/vanna/.dockerignore +18 -0
- package/templates/dataif/services/vanna/Dockerfile +12 -0
- package/templates/dataif/services/vanna/app/config.py +57 -0
- package/templates/dataif/services/vanna/app/main.py +108 -0
- package/templates/dataif/services/vanna/app/runtime_config.py +114 -0
- package/templates/dataif/services/vanna/app/sql_guard.py +123 -0
- package/templates/dataif/services/vanna/app/vanna_engine.py +382 -0
- package/templates/dataif/services/vanna/requirements.txt +8 -0
- package/templates/dataif/services/web/.dockerignore +13 -0
- package/templates/dataif/services/web/Dockerfile +16 -0
- package/templates/dataif/services/web/index.html +12 -0
- package/templates/dataif/services/web/nginx.conf +74 -0
- package/templates/dataif/services/web/package-lock.json +4397 -0
- package/templates/dataif/services/web/package.json +32 -0
- package/templates/dataif/services/web/postcss.config.mjs +5 -0
- package/templates/dataif/services/web/src/App.jsx +2817 -0
- package/templates/dataif/services/web/src/adminAuth.js +245 -0
- package/templates/dataif/services/web/src/assets/avatar_placeholder.png +0 -0
- package/templates/dataif/services/web/src/assets/github_logo_icon_229278.svg +1 -0
- package/templates/dataif/services/web/src/assets/if-logo.png +0 -0
- package/templates/dataif/services/web/src/assets/if.svg +0 -0
- package/templates/dataif/services/web/src/assets/pnp-horizontal.svg +1 -0
- package/templates/dataif/services/web/src/components/AppHeader.jsx +233 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/base-components/mobile-header.tsx +56 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/base-components/nav-account-card.tsx +209 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/base-components/nav-item-button.tsx +67 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/base-components/nav-item.tsx +108 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/base-components/nav-list.tsx +83 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/config.ts +23 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/header-navigation.tsx +240 -0
- package/templates/dataif/services/web/src/components/application/pagination/pagination-base.tsx +376 -0
- package/templates/dataif/services/web/src/components/application/pagination/pagination-dot.tsx +52 -0
- package/templates/dataif/services/web/src/components/application/pagination/pagination-line.tsx +48 -0
- package/templates/dataif/services/web/src/components/application/pagination/pagination.tsx +328 -0
- package/templates/dataif/services/web/src/components/application/tabs/tabs.tsx +223 -0
- package/templates/dataif/services/web/src/components/base/avatar/avatar-label-group.tsx +28 -0
- package/templates/dataif/services/web/src/components/base/avatar/avatar.tsx +129 -0
- package/templates/dataif/services/web/src/components/base/avatar/base-components/avatar-add-button.tsx +32 -0
- package/templates/dataif/services/web/src/components/base/avatar/base-components/avatar-company-icon.tsx +24 -0
- package/templates/dataif/services/web/src/components/base/avatar/base-components/avatar-online-indicator.tsx +29 -0
- package/templates/dataif/services/web/src/components/base/avatar/base-components/index.tsx +4 -0
- package/templates/dataif/services/web/src/components/base/avatar/base-components/verified-tick.tsx +32 -0
- package/templates/dataif/services/web/src/components/base/badges/badge-types.ts +264 -0
- package/templates/dataif/services/web/src/components/base/badges/badges.tsx +415 -0
- package/templates/dataif/services/web/src/components/base/button-group/button-group.tsx +104 -0
- package/templates/dataif/services/web/src/components/base/buttons/button.tsx +267 -0
- package/templates/dataif/services/web/src/components/base/input/hint-text.tsx +31 -0
- package/templates/dataif/services/web/src/components/base/input/input.tsx +269 -0
- package/templates/dataif/services/web/src/components/base/input/label.tsx +48 -0
- package/templates/dataif/services/web/src/components/base/radio-buttons/radio-buttons.tsx +127 -0
- package/templates/dataif/services/web/src/components/base/select/combobox.tsx +150 -0
- package/templates/dataif/services/web/src/components/base/select/multi-select.tsx +361 -0
- package/templates/dataif/services/web/src/components/base/select/popover.tsx +32 -0
- package/templates/dataif/services/web/src/components/base/select/select-item.tsx +95 -0
- package/templates/dataif/services/web/src/components/base/select/select-native.tsx +67 -0
- package/templates/dataif/services/web/src/components/base/select/select.tsx +144 -0
- package/templates/dataif/services/web/src/components/base/tags/base-components/tag-close-x.tsx +32 -0
- package/templates/dataif/services/web/src/components/base/tooltip/tooltip.tsx +107 -0
- package/templates/dataif/services/web/src/components/foundations/dot-icon.tsx +22 -0
- package/templates/dataif/services/web/src/components/foundations/logo/untitledui-logo-minimal.tsx +170 -0
- package/templates/dataif/services/web/src/components/foundations/logo/untitledui-logo.tsx +58 -0
- package/templates/dataif/services/web/src/hooks/use-breakpoint.ts +34 -0
- package/templates/dataif/services/web/src/hooks/use-resize-observer.ts +67 -0
- package/templates/dataif/services/web/src/main.jsx +14 -0
- package/templates/dataif/services/web/src/providers/theme-provider.jsx +62 -0
- package/templates/dataif/services/web/src/styles/globals.css +60 -0
- package/templates/dataif/services/web/src/styles/theme.css +1326 -0
- package/templates/dataif/services/web/src/styles/typography.css +430 -0
- package/templates/dataif/services/web/src/styles.css +1287 -0
- package/templates/dataif/services/web/src/utils/cx.ts +24 -0
- package/templates/dataif/services/web/src/utils/is-react-component.ts +33 -0
- package/templates/dataif/services/web/vite.config.js +14 -0
- package/templates/dataif/sql/ddl/001_schemas.sql +6 -0
- package/templates/dataif/sql/ddl/003_pnp_raw_staging_curated.sql +699 -0
- package/templates/dataif/sql/migrations/001_pnp_phase1_backfill.sql +3 -0
- package/templates/dataif/sql/migrations/002_pnp_phase2_admin_config_backfill.sql +184 -0
- package/templates/dataif/sql/migrations/003_pnp_phase3_raw_tabular_backfill.sql +3 -0
- package/templates/dataif/sql/migrations/004_pnp_phase3_raw_backfill_support_index.sql +3 -0
- package/templates/dataif/sql/migrations/005_pnp_phase7_staging_support_indexes.sql +2 -0
- package/templates/dataif/sql/migrations/006_pnp_phase7_staging_autovacuum_tuning.sql +2 -0
- package/templates/dataif/sql/migrations/007_pnp_phase7b_run_packages.sql +20 -0
- package/templates/dataif/sql/migrations/008_pnp_phase7a_pipeline_endpoints.sql +169 -0
- package/templates/dataif/sql/migrations/009_pnp_phase8_curated.sql +35 -0
- package/templates/dataif/sql/migrations/010_pnp_phase10_staging_incremental_upsert.sql +3 -0
- package/templates/dataif/sql/migrations/010_pnp_pipeline_uuid.sql +51 -0
- package/templates/dataif/sql/migrations/011_app_settings.sql +7 -0
- package/templates/dataif/sql/staging/020_pnp_matriculas.sql +112 -0
- package/templates/dataif/sql/staging/030_pnp_eficiencia_academica.sql +83 -0
- package/templates/dataif/sql/staging/040_pnp_servidores.sql +90 -0
- package/templates/dataif/sql/staging/050_pnp_financeiro.sql +72 -0
- package/templates/dataif/sql/views_curated/003_vw_pnp_microdados_admin.sql +160 -0
- package/templates/dataif/sql/views_curated/004_mv_pnp_dashboard_fast.sql +204 -0
- package/templates/dataif/sql/views_curated/010_vw_pnp_admin_ingestao.sql +51 -0
- package/templates/dataif/sql/views_curated/020_vw_pnp_qualidade_dados.sql +114 -0
- package/templates/dataif/sql/views_curated/030_vw_pnp_matriculas.sql +67 -0
- package/templates/dataif/sql/views_curated/040_vw_pnp_eficiencia.sql +33 -0
- package/templates/dataif/sql/views_curated/050_vw_pnp_servidores.sql +30 -0
- package/templates/dataif/sql/views_curated/060_vw_pnp_financeiro.sql +22 -0
- package/templates/dataif/sql/views_curated/070_vw_pnp_vanna.sql +115 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_eficiencia_situacao AS
|
|
2
|
+
SELECT
|
|
3
|
+
run_id,
|
|
4
|
+
instance_key,
|
|
5
|
+
ano,
|
|
6
|
+
instituicao,
|
|
7
|
+
regiao,
|
|
8
|
+
uf,
|
|
9
|
+
municipio,
|
|
10
|
+
sexo,
|
|
11
|
+
cor_raca,
|
|
12
|
+
renda_familiar,
|
|
13
|
+
faixa_etaria,
|
|
14
|
+
categoria_situacao,
|
|
15
|
+
situacao_matricula,
|
|
16
|
+
matricula_atendida,
|
|
17
|
+
COUNT(*) AS registros
|
|
18
|
+
FROM staging.pnp_eficiencia_academica
|
|
19
|
+
GROUP BY
|
|
20
|
+
run_id,
|
|
21
|
+
instance_key,
|
|
22
|
+
ano,
|
|
23
|
+
instituicao,
|
|
24
|
+
regiao,
|
|
25
|
+
uf,
|
|
26
|
+
municipio,
|
|
27
|
+
sexo,
|
|
28
|
+
cor_raca,
|
|
29
|
+
renda_familiar,
|
|
30
|
+
faixa_etaria,
|
|
31
|
+
categoria_situacao,
|
|
32
|
+
situacao_matricula,
|
|
33
|
+
matricula_atendida;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_servidores_quadro AS
|
|
2
|
+
SELECT
|
|
3
|
+
run_id,
|
|
4
|
+
instance_key,
|
|
5
|
+
ano,
|
|
6
|
+
instituicao,
|
|
7
|
+
regiao,
|
|
8
|
+
classe,
|
|
9
|
+
jornada_trabalho,
|
|
10
|
+
titulacao,
|
|
11
|
+
rsc,
|
|
12
|
+
vinculo_carreira,
|
|
13
|
+
vinculo_contrato,
|
|
14
|
+
vinculo_professor,
|
|
15
|
+
COUNT(*) AS servidores,
|
|
16
|
+
SUM(numero_registros) AS total_registros
|
|
17
|
+
FROM staging.pnp_servidores
|
|
18
|
+
GROUP BY
|
|
19
|
+
run_id,
|
|
20
|
+
instance_key,
|
|
21
|
+
ano,
|
|
22
|
+
instituicao,
|
|
23
|
+
regiao,
|
|
24
|
+
classe,
|
|
25
|
+
jornada_trabalho,
|
|
26
|
+
titulacao,
|
|
27
|
+
rsc,
|
|
28
|
+
vinculo_carreira,
|
|
29
|
+
vinculo_contrato,
|
|
30
|
+
vinculo_professor;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_financeiro_execucao AS
|
|
2
|
+
SELECT
|
|
3
|
+
run_id,
|
|
4
|
+
instance_key,
|
|
5
|
+
ano,
|
|
6
|
+
nome_uo,
|
|
7
|
+
uo,
|
|
8
|
+
cod_acao,
|
|
9
|
+
nome_acao,
|
|
10
|
+
grupo_despesa,
|
|
11
|
+
COUNT(*) AS registros,
|
|
12
|
+
SUM(liquidacoes_totais) AS liquidacoes_totais
|
|
13
|
+
FROM staging.pnp_financeiro
|
|
14
|
+
GROUP BY
|
|
15
|
+
run_id,
|
|
16
|
+
instance_key,
|
|
17
|
+
ano,
|
|
18
|
+
nome_uo,
|
|
19
|
+
uo,
|
|
20
|
+
cod_acao,
|
|
21
|
+
nome_acao,
|
|
22
|
+
grupo_despesa;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_vanna_catalogo AS
|
|
2
|
+
SELECT
|
|
3
|
+
'vw_pnp_admin_ingestao' AS relation_name,
|
|
4
|
+
'administrativo' AS relation_group,
|
|
5
|
+
'Resumo operacional das execucoes da pipeline PNP.' AS relation_description
|
|
6
|
+
UNION ALL
|
|
7
|
+
SELECT
|
|
8
|
+
'vw_pnp_qualidade_dados',
|
|
9
|
+
'administrativo',
|
|
10
|
+
'Indicadores de completude e consistencia por tipo de microdado.'
|
|
11
|
+
UNION ALL
|
|
12
|
+
SELECT
|
|
13
|
+
'vw_pnp_matriculas_perfil',
|
|
14
|
+
'matriculas',
|
|
15
|
+
'Agregacoes de matriculas por perfil socioeconomico e situacao.'
|
|
16
|
+
UNION ALL
|
|
17
|
+
SELECT
|
|
18
|
+
'vw_pnp_matriculas_oferta',
|
|
19
|
+
'matriculas',
|
|
20
|
+
'Agregacoes de matriculas por curso, oferta e eixo tecnologico.'
|
|
21
|
+
UNION ALL
|
|
22
|
+
SELECT
|
|
23
|
+
'vw_pnp_eficiencia_situacao',
|
|
24
|
+
'eficiencia',
|
|
25
|
+
'Agregacoes de eficiencia academica por categoria e situacao.'
|
|
26
|
+
UNION ALL
|
|
27
|
+
SELECT
|
|
28
|
+
'vw_pnp_servidores_quadro',
|
|
29
|
+
'servidores',
|
|
30
|
+
'Agregacoes do quadro de servidores por carreira e titulacao.'
|
|
31
|
+
UNION ALL
|
|
32
|
+
SELECT
|
|
33
|
+
'vw_pnp_financeiro_execucao',
|
|
34
|
+
'financeiro',
|
|
35
|
+
'Agregacoes da execucao financeira por ano, UO e grupo de despesa.';
|
|
36
|
+
|
|
37
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_vanna_resumo AS
|
|
38
|
+
SELECT
|
|
39
|
+
run_id,
|
|
40
|
+
instance_key,
|
|
41
|
+
'matriculas' AS dominio,
|
|
42
|
+
'matriculas' AS indicador,
|
|
43
|
+
ano,
|
|
44
|
+
instituicao,
|
|
45
|
+
regiao,
|
|
46
|
+
uf,
|
|
47
|
+
municipio,
|
|
48
|
+
SUM(matriculas)::NUMERIC AS valor
|
|
49
|
+
FROM curated.vw_pnp_matriculas_perfil
|
|
50
|
+
GROUP BY
|
|
51
|
+
run_id,
|
|
52
|
+
instance_key,
|
|
53
|
+
ano,
|
|
54
|
+
instituicao,
|
|
55
|
+
regiao,
|
|
56
|
+
uf,
|
|
57
|
+
municipio
|
|
58
|
+
UNION ALL
|
|
59
|
+
SELECT
|
|
60
|
+
run_id,
|
|
61
|
+
instance_key,
|
|
62
|
+
'eficiencia' AS dominio,
|
|
63
|
+
'registros' AS indicador,
|
|
64
|
+
ano,
|
|
65
|
+
instituicao,
|
|
66
|
+
regiao,
|
|
67
|
+
uf,
|
|
68
|
+
municipio,
|
|
69
|
+
SUM(registros)::NUMERIC AS valor
|
|
70
|
+
FROM curated.vw_pnp_eficiencia_situacao
|
|
71
|
+
GROUP BY
|
|
72
|
+
run_id,
|
|
73
|
+
instance_key,
|
|
74
|
+
ano,
|
|
75
|
+
instituicao,
|
|
76
|
+
regiao,
|
|
77
|
+
uf,
|
|
78
|
+
municipio
|
|
79
|
+
UNION ALL
|
|
80
|
+
SELECT
|
|
81
|
+
run_id,
|
|
82
|
+
instance_key,
|
|
83
|
+
'servidores' AS dominio,
|
|
84
|
+
'total_registros' AS indicador,
|
|
85
|
+
ano,
|
|
86
|
+
instituicao,
|
|
87
|
+
regiao,
|
|
88
|
+
NULL::TEXT AS uf,
|
|
89
|
+
NULL::TEXT AS municipio,
|
|
90
|
+
SUM(total_registros)::NUMERIC AS valor
|
|
91
|
+
FROM curated.vw_pnp_servidores_quadro
|
|
92
|
+
GROUP BY
|
|
93
|
+
run_id,
|
|
94
|
+
instance_key,
|
|
95
|
+
ano,
|
|
96
|
+
instituicao,
|
|
97
|
+
regiao
|
|
98
|
+
UNION ALL
|
|
99
|
+
SELECT
|
|
100
|
+
run_id,
|
|
101
|
+
instance_key,
|
|
102
|
+
'financeiro' AS dominio,
|
|
103
|
+
'liquidacoes_totais' AS indicador,
|
|
104
|
+
ano,
|
|
105
|
+
nome_uo AS instituicao,
|
|
106
|
+
NULL::TEXT AS regiao,
|
|
107
|
+
NULL::TEXT AS uf,
|
|
108
|
+
NULL::TEXT AS municipio,
|
|
109
|
+
SUM(liquidacoes_totais)::NUMERIC AS valor
|
|
110
|
+
FROM curated.vw_pnp_financeiro_execucao
|
|
111
|
+
GROUP BY
|
|
112
|
+
run_id,
|
|
113
|
+
instance_key,
|
|
114
|
+
ano,
|
|
115
|
+
nome_uo;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
|
|
6
|
+
if [ -f "${script_dir}/.env.example" ]; then
|
|
7
|
+
template_file="${script_dir}/.env.example"
|
|
8
|
+
default_env_file="${script_dir}/.env"
|
|
9
|
+
compose_file="${script_dir}/docker-compose.yml"
|
|
10
|
+
elif [ -f "${script_dir}/../infra/.env.example" ]; then
|
|
11
|
+
template_file="${script_dir}/../infra/.env.example"
|
|
12
|
+
default_env_file="${script_dir}/../infra/.env"
|
|
13
|
+
compose_file="${script_dir}/../infra/docker-compose.yml"
|
|
14
|
+
else
|
|
15
|
+
printf 'Nao encontrei .env.example.\n' >&2
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
env_file="${DATAIF_ENV_FILE:-${default_env_file}}"
|
|
20
|
+
|
|
21
|
+
input_fd=0
|
|
22
|
+
if [ -e /dev/tty ] && (: </dev/tty) 2>/dev/null; then
|
|
23
|
+
exec 3</dev/tty
|
|
24
|
+
input_fd=3
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
random_secret() {
|
|
28
|
+
if command -v openssl >/dev/null 2>&1; then
|
|
29
|
+
openssl rand -base64 32 | tr -d '\n'
|
|
30
|
+
else
|
|
31
|
+
local secret
|
|
32
|
+
set +o pipefail
|
|
33
|
+
secret="$(LC_ALL=C tr -dc 'A-Za-z0-9_=-' </dev/urandom | head -c 48)"
|
|
34
|
+
set -o pipefail
|
|
35
|
+
printf '%s' "${secret}"
|
|
36
|
+
fi
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
read_value() {
|
|
40
|
+
local label="$1"
|
|
41
|
+
local default_value="$2"
|
|
42
|
+
local value
|
|
43
|
+
|
|
44
|
+
if ! read -r -u "${input_fd}" -p "${label} [${default_value}]: " value; then
|
|
45
|
+
value=""
|
|
46
|
+
fi
|
|
47
|
+
printf '%s' "${value:-${default_value}}"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
read_secret() {
|
|
51
|
+
local label="$1"
|
|
52
|
+
local default_value="$2"
|
|
53
|
+
local value
|
|
54
|
+
|
|
55
|
+
if ! read -r -s -u "${input_fd}" -p "${label} [Enter gera segredo]: " value; then
|
|
56
|
+
value=""
|
|
57
|
+
fi
|
|
58
|
+
printf '\n' >&2
|
|
59
|
+
printf '%s' "${value:-${default_value}}"
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
set_env() {
|
|
63
|
+
local key="$1"
|
|
64
|
+
local value="$2"
|
|
65
|
+
local tmp_file
|
|
66
|
+
|
|
67
|
+
tmp_file="$(mktemp)"
|
|
68
|
+
awk -v key="${key}" -v value="${value}" '
|
|
69
|
+
BEGIN { done = 0 }
|
|
70
|
+
$0 ~ "^" key "=" {
|
|
71
|
+
print key "=" value
|
|
72
|
+
done = 1
|
|
73
|
+
next
|
|
74
|
+
}
|
|
75
|
+
{ print }
|
|
76
|
+
END {
|
|
77
|
+
if (!done) {
|
|
78
|
+
print key "=" value
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
' "${env_file}" > "${tmp_file}"
|
|
82
|
+
mv "${tmp_file}" "${env_file}"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
printf 'Configurando DataIF .env\n'
|
|
86
|
+
printf 'Template: %s\n' "${template_file}"
|
|
87
|
+
printf 'Destino: %s\n\n' "${env_file}"
|
|
88
|
+
|
|
89
|
+
if [ -f "${env_file}" ] && [ "${DATAIF_FORCE_ENV:-false}" = "true" ]; then
|
|
90
|
+
cp "${template_file}" "${env_file}"
|
|
91
|
+
elif [ -f "${env_file}" ]; then
|
|
92
|
+
overwrite="$(read_value "Sobrescrever .env existente? (s/N)" "N")"
|
|
93
|
+
case "${overwrite}" in
|
|
94
|
+
s|S|sim|SIM) cp "${template_file}" "${env_file}" ;;
|
|
95
|
+
*) printf 'Mantendo arquivo existente.\n' ;;
|
|
96
|
+
esac
|
|
97
|
+
else
|
|
98
|
+
cp "${template_file}" "${env_file}"
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
public_base_url="$(read_value "URL publica da aplicacao" "http://localhost:5173")"
|
|
102
|
+
web_port="$(read_value "Porta Web" "5173")"
|
|
103
|
+
api_port="$(read_value "Porta API" "8000")"
|
|
104
|
+
postgres_port="$(read_value "Porta Postgres host" "5433")"
|
|
105
|
+
metabase_port="$(read_value "Porta Metabase host" "3000")"
|
|
106
|
+
airflow_port="$(read_value "Porta Airflow host" "8088")"
|
|
107
|
+
keycloak_port="$(read_value "Porta Keycloak host" "8081")"
|
|
108
|
+
vanna_port="$(read_value "Porta Vanna host" "9000")"
|
|
109
|
+
image_registry="$(read_value "Registry imagens" "docker.io/dataif")"
|
|
110
|
+
image_tag="$(read_value "Tag imagens" "latest")"
|
|
111
|
+
admin_email="$(read_value "Email admin" "admin@dataif.local")"
|
|
112
|
+
llm_provider="$(read_value "Provider Vanna (ollama/maritaca)" "ollama")"
|
|
113
|
+
maritaca_key=""
|
|
114
|
+
|
|
115
|
+
if [ "${llm_provider}" = "maritaca" ]; then
|
|
116
|
+
maritaca_key="$(read_secret "Chave Maritaca" "")"
|
|
117
|
+
fi
|
|
118
|
+
|
|
119
|
+
set_env COMPOSE_PROJECT_NAME "$(read_value "Nome projeto Compose" "dataif")"
|
|
120
|
+
set_env DATAIF_IMAGE_REGISTRY "${image_registry}"
|
|
121
|
+
set_env DATAIF_IMAGE_TAG "${image_tag}"
|
|
122
|
+
set_env WEB_PORT "${web_port}"
|
|
123
|
+
set_env API_PORT "${api_port}"
|
|
124
|
+
set_env POSTGRES_EXPOSE_PORT "${postgres_port}"
|
|
125
|
+
set_env METABASE_PORT "${metabase_port}"
|
|
126
|
+
set_env AIRFLOW_PORT "${airflow_port}"
|
|
127
|
+
set_env KEYCLOAK_PORT "${keycloak_port}"
|
|
128
|
+
set_env VANNA_PORT "${vanna_port}"
|
|
129
|
+
set_env METABASE_SITE_URL "${public_base_url%/}/metabase"
|
|
130
|
+
set_env METABASE_ADMIN_EMAIL "${admin_email}"
|
|
131
|
+
set_env AIRFLOW_ADMIN_EMAIL "${admin_email}"
|
|
132
|
+
set_env VANNA_LLM_PROVIDER "${llm_provider}"
|
|
133
|
+
set_env VANNA_MARITACA_API_KEY "${maritaca_key}"
|
|
134
|
+
|
|
135
|
+
set_env POSTGRES_SUPERUSER_PASSWORD "$(read_secret "Senha Postgres superuser" "$(random_secret)")"
|
|
136
|
+
set_env DATAIF_ETL_PASSWORD "$(read_secret "Senha usuario ETL" "$(random_secret)")"
|
|
137
|
+
set_env DATAIF_METABASE_PASSWORD "$(read_secret "Senha usuario Metabase" "$(random_secret)")"
|
|
138
|
+
set_env DATAIF_VANNA_PASSWORD "$(read_secret "Senha usuario Vanna" "$(random_secret)")"
|
|
139
|
+
set_env AIRFLOW_DB_PASSWORD "$(read_secret "Senha banco Airflow" "$(random_secret)")"
|
|
140
|
+
set_env METABASE_APP_DB_PASSWORD "$(read_secret "Senha banco Metabase" "$(random_secret)")"
|
|
141
|
+
set_env AIRFLOW_ADMIN_PASSWORD "$(read_secret "Senha admin Airflow" "$(random_secret)")"
|
|
142
|
+
set_env METABASE_ADMIN_PASSWORD "$(read_secret "Senha admin Metabase" "$(random_secret)")"
|
|
143
|
+
set_env KEYCLOAK_ADMIN_PASSWORD "$(read_secret "Senha admin Keycloak" "$(random_secret)")"
|
|
144
|
+
set_env METABASE_EMBED_SECRET "$(read_secret "Segredo embed Metabase" "$(random_secret)")"
|
|
145
|
+
|
|
146
|
+
chmod 600 "${env_file}"
|
|
147
|
+
|
|
148
|
+
printf '\n.env configurado: %s\n' "${env_file}"
|
|
149
|
+
printf 'Valide com: docker compose --env-file %s -f %s config >/dev/null\n' "${env_file}" "${compose_file}"
|