Skip to content

Commit

Permalink
Merge branch 'staging/add-scripts' of https://github.com/basedosdados…
Browse files Browse the repository at this point in the history
…/pipelines into staging/add-scripts
  • Loading branch information
laura-l-amaral committed Jan 12, 2024
2 parents 83a3d1c + 59e0365 commit df90733
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
15 changes: 10 additions & 5 deletions scripts/link_directory_metadata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from typing import Optional

import basedosdados as bd
import pandas as pd

Expand Down Expand Up @@ -94,9 +95,11 @@ def get_directory_column_id(
)
return coluna["_id"]

raise(ValueError(
f"\nWARNING - Unable to find the directory column with the following information: \n\tcolumn_name: {directory_column_name} \n\ttable: {directory_table_name}"
))
raise (
ValueError(
f"\nWARNING - Unable to find the directory column with the following information: \n\tcolumn_name: {directory_column_name} \n\ttable: {directory_table_name}"
)
)


def modify_directory_metadata(column_id: str, directory_id: str, backend) -> None:
Expand Down Expand Up @@ -128,7 +131,9 @@ def modify_directory_metadata(column_id: str, directory_id: str, backend) -> Non
return None


def select_columns(df: pd.DataFrame, not_column_name: list, remove_already_done: bool=False) -> list:
def select_columns(
df: pd.DataFrame, not_column_name: list, remove_already_done: bool = False
) -> list:
descricao = df["name"].str.contains("descricao")
diretorio = df["table.dataset.fullSlug"].str.contains("diretorios")

Expand Down Expand Up @@ -177,7 +182,7 @@ def link_directory_metadata(
not_matching_pattern: list,
ignore_previously_linked_columns: bool,
ready_to_change_metadata: bool,
)-> None:
) -> None:
"""
This function searches for columns within the metadata that match the specified `matching_column_pattern`.
It performs filtering based on defined criteria and presents a list of selected columns.
Expand Down
8 changes: 5 additions & 3 deletions scripts/upload_columns.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import json
from io import StringIO
from typing import Dict

import numpy as np
Expand All @@ -9,8 +8,11 @@
from basedosdados import backend as b
from link_directory_metadata import get_directory_column_id

from pipelines.utils.apply_architecture_to_dataframe.utils import (
read_architecture_table,
)
from pipelines.utils.metadata.utils import get_headers
from pipelines.utils.apply_architecture_to_dataframe.utils import read_architecture_table


def create_column(
backend: b.Backend,
Expand Down Expand Up @@ -51,7 +53,7 @@ def create_column(
pretty_json = json.dumps(response, indent=4)
print(pretty_json)
return False

return True


Expand Down

0 comments on commit df90733

Please sign in to comment.