Commit dc07bb88 authored by Erly Villaroel's avatar Erly Villaroel

DAG Reset process

parent b9272727
...@@ -48,7 +48,7 @@ def update_new_process(conf: List[Dict[str, Any]], status: str, tasks: Dict[str, ...@@ -48,7 +48,7 @@ def update_new_process(conf: List[Dict[str, Any]], status: str, tasks: Dict[str,
tasks.update(last_tasks) tasks.update(last_tasks)
conf.pop(-1) conf.pop(-1)
current_datetime = str(datetime_by_tzone(timezone, '%Y-%m-%d %H:%M:%S')) current_datetime = str(datetime_by_tzone(timezone, '%Y-%m-%d %H:%M:%S'))
new_process = {"date": current_datetime, "status": status, "tasks": tasks, "created_tables": created_tables} new_process = {"date": current_datetime, "status": status, "tasks": tasks, "objects_created": created_tables}
if current_period == processed_period and isinstance(conf, List): if current_period == processed_period and isinstance(conf, List):
conf.append(new_process) conf.append(new_process)
else: else:
......
...@@ -140,6 +140,7 @@ def generate_and_deploy(command: str, intern_conn, params: Dict[str, Any], timez ...@@ -140,6 +140,7 @@ def generate_and_deploy(command: str, intern_conn, params: Dict[str, Any], timez
dataframe[campo] = pd.to_datetime(dataframe[campo]).dt.date dataframe[campo] = pd.to_datetime(dataframe[campo]).dt.date
# elif campos[campo] == DataTypeEnum.DATETIME.name: # datetime: # elif campos[campo] == DataTypeEnum.DATETIME.name: # datetime:
# dataframe[campo] = pd.to_datetime(dataframe[campo], format='%Y-%m-%d %H:%M:%S') # dataframe[campo] = pd.to_datetime(dataframe[campo], format='%Y-%m-%d %H:%M:%S')
dataframe = dataframe.drop("INTERN_ID_BCOM", axis=1, errors='ignore') dataframe = dataframe.drop("INTERN_ID_BCOM", axis=1, errors='ignore')
logger.debug(dataframe) logger.debug(dataframe)
dataframe.to_csv(tmp_file, sep=delimiter, index=False, mode='a', header=header) dataframe.to_csv(tmp_file, sep=delimiter, index=False, mode='a', header=header)
......
...@@ -55,15 +55,15 @@ app: ...@@ -55,15 +55,15 @@ app:
delimiter: '|' delimiter: '|'
tmp_path: /tmp tmp_path: /tmp
s3_params: s3_params:
ESTUDIANTES_1: tabla4:
bucket: pruebairflow bucket: pruebairflow
prefix: bcom_results prefix: bcom_results
connection_id: prueba_af connection_id: prueba_af
ESTUDIANTES_11: tabla1:
bucket: pruebairflow bucket: pruebairflow
prefix: bcom_results prefix: bcom_results
connection_id: prueba_af connection_id: prueba_af
CATALOGO_PROMOCIONES: tabla2:
bucket: pruebairflow bucket: pruebairflow
prefix: bcom_results prefix: bcom_results
connection_id: prueba_af connection_id: prueba_af
...@@ -74,7 +74,7 @@ app: ...@@ -74,7 +74,7 @@ app:
connection_id: conn_script connection_id: conn_script
filename: report_<datetime>.xlsx filename: report_<datetime>.xlsx
datetime_pattern: '%Y-%m-%d %H:%M:%S' datetime_pattern: '%Y-%m-%d %H:%M:%S'
procedure: definitions:
filepath: "/opt/airflow/dags/procedure_prueba.json" filepath: "/opt/airflow/dags/procedure_prueba.json"
...@@ -112,7 +112,7 @@ def set_dag(): ...@@ -112,7 +112,7 @@ def set_dag():
control_s3 = conf["control"]["s3_params"] control_s3 = conf["control"]["s3_params"]
timezone = conf["timezone"] timezone = conf["timezone"]
# NUEVA VARIABLE # NUEVA VARIABLE
procedure = conf["procedure"] procedure = conf["definitions"]
control_extractor = PythonOperator( control_extractor = PythonOperator(
task_id="CONTROL-EXTRACTOR", task_id="CONTROL-EXTRACTOR",
python_callable=extract_last_control, python_callable=extract_last_control,
......
...@@ -138,7 +138,6 @@ def set_dag(): ...@@ -138,7 +138,6 @@ def set_dag():
conf_path = MAIN_PATH + "dag_conf.yml" conf_path = MAIN_PATH + "dag_conf.yml"
with open(conf_path) as f: with open(conf_path) as f:
data = yaml.load(f, Loader=SafeLoader) data = yaml.load(f, Loader=SafeLoader)
logger.info(f"CONFIGURACIÓN: {data}")
conf = data["app"] conf = data["app"]
with DAG(DAG_NAME, default_args=DEFAULT_ARGS, description="Proceso que extrae y transforma", with DAG(DAG_NAME, default_args=DEFAULT_ARGS, description="Proceso que extrae y transforma",
schedule_interval=conf["schedule"], tags=["DAG BCOM - SQL TRANSFORMATIONS"], catchup=False) as dag: schedule_interval=conf["schedule"], tags=["DAG BCOM - SQL TRANSFORMATIONS"], catchup=False) as dag:
...@@ -152,7 +151,7 @@ def set_dag(): ...@@ -152,7 +151,7 @@ def set_dag():
control_s3 = conf["control"]["s3_params"] control_s3 = conf["control"]["s3_params"]
timezone = conf["timezone"] timezone = conf["timezone"]
# NUEVA VARIABLE # NUEVA VARIABLE
procedure = conf["procedure"] procedure = conf["definitions"]
# Scripts extraction # Scripts extraction
extract_mask = conf["source_mask"] extract_mask = conf["source_mask"]
transform_mask = conf["transformation_mask"] transform_mask = conf["transformation_mask"]
......
[ [
{ {
"identifier": "obtenerEstudiantes", "identifier": "ModificarTabla4",
"transformation_store_procedure": true "transformation_store_procedure": true
}, },
{ {
"identifier": "TempEstudiantes", "identifier" : "UnionYInsert",
"transformation_store_procedure": true
},
{
"identifier": "TempTabla",
"temp_table" : true "temp_table" : true
}, },
{ {
"identifier": "ESTUDIANTES_11", "identifier": "tabla1",
"fields": [ "fields": [
{ {
"name": "ID", "name": "id",
"datatype": "NUMBER", "datatype": "NUMBER",
"decimal_precision": 0 "decimal_precision": 0
}, },
{ {
"name": "Nombre", "name": "nombre",
"datatype": "TEXT", "datatype": "TEXT",
"maxLength": 50 "maxLength": 50
}, },
{ {
"name": "Apellido", "name": "fecha_nacimiento",
"datatype": "DATE"
}
],
"indexes": [
{
"name" : "indice1",
"index_fields": [
"id"
]
}
],
"save_output" : false
},
{
"identifier": "tabla2",
"fields": [
{
"name": "id",
"datatype": "NUMBER",
"decimal_precision": 0
},
{
"name": "apellido",
"datatype": "TEXT", "datatype": "TEXT",
"maxLength": 50 "maxLength": 50
}, },
{ {
"name": "Edad", "name": "fecha_registro",
"datatype": "DATETIME"
}
],
"indexes": [
{
"name" : "indice1",
"index_fields": [
"id"
]
}
],
"save_output" : false
},
{
"identifier": "tabla3",
"fields": [
{
"name": "id",
"datatype": "NUMBER", "datatype": "NUMBER",
"decimal_precision": 0 "decimal_precision": 0
}, },
{ {
"name": "CorreoElectronico", "name": "edad",
"datatype": "TEXT", "datatype": "NUMBER",
"maxLength": 100 "decimal_precision": 0
},
{
"name": "fecha_actualizacion",
"datatype": "DATETIME"
} }
], ],
"indexes": [ "indexes": [
{ {
"name" : "indice1", "name" : "indice1",
"index_fields": [ "index_fields": [
"ID" "id"
] ]
} }
], ],
"save_output" : true "save_output" : false
}, },
{ {
"identifier": "ESTUDIANTES_1", "identifier": "tabla4",
"fields": [ "fields": [
{ {
"name": "id", "name": "id",
"datatype": "NUMBER", "datatype": "NUMBER",
"decimal_precision": 0 "decimal_precision": 0
}, },
{
"name": "nombre",
"datatype": "TEXT",
"maxLength": 50
},
{ {
"name": "fecha", "name": "fecha",
"datatype": "DATE" "datatype": "DATE"
}, },
{ {
"name": "fecha_tiempo", "name": "fecha_2",
"datatype": "DATETIME"
},
{
"name": "fecha_3",
"datatype": "DATETIME" "datatype": "DATETIME"
} }
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment