Commit 35422d81 authored by Cristian Aguirre's avatar Cristian Aguirre

Init Commit

parent 5e15c504
Pipeline #396 failed with stages
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"cells": [
{
"cell_type": "markdown",
"id": "faab864f-8e6d-4305-82bc-bc407cc8af57",
"metadata": {},
"source": [
"### Transformadores sobre índices"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f1da31b6-6ddf-4d96-a809-e94226f3e8c3",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import json\n",
"import requests\n",
"from opensearchpy import OpenSearch\n",
"import time\n",
"import random"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "9b28eba4-4776-442e-9ad0-0eca5be7fbbd",
"metadata": {},
"outputs": [],
"source": [
"host = 'localhost'\n",
"port = 9200"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "e7efb345-a603-4f20-b42f-97954c4d1fce",
"metadata": {},
"outputs": [],
"source": [
"auth = ('admin', 'admin')\n",
"headers = {\"Content-Type\": \"application/json; charset=utf-8\"}"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "d159eee9-d26e-4c9b-b5bb-59a231c48a30",
"metadata": {},
"outputs": [],
"source": [
"client = OpenSearch(\n",
" hosts = [{'host': host, 'port': port}],\n",
" http_compress = True, # enables gzip compression for request bodies\n",
" http_auth = auth,\n",
" use_ssl = True,\n",
" verify_certs = False,\n",
" ssl_assert_hostname = False,\n",
" ssl_show_warn = False\n",
")"
]
},
{
"cell_type": "markdown",
"id": "ba3828c7-8b80-4d13-afa7-979d085b3a55",
"metadata": {},
"source": [
"### Transformacion para Detector Gross - Legalizaciones"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "ec7a7e2d-267a-4d65-851a-7ae3deb703bb",
"metadata": {},
"outputs": [],
"source": [
"NOMBRE_TRANSFORMACION = \"planta_ausentismo_transformation\"\n",
"\n",
"url = \"https://localhost:9200/_plugins/_transform/\" + NOMBRE_TRANSFORMACION\n",
"data = {\n",
" \"transform\": {\n",
" \"schedule\": {\n",
" \"interval\": {\n",
" \"start_time\": 1693329303541,\n",
" \"period\": 1,\n",
" \"unit\": \"Minutes\"\n",
" }\n",
" },\n",
" \"enabled\": True,\n",
" \"description\": \"Transformador de Planta y Ausentismo\",\n",
" \"source_index\": \"planta\",\n",
" \"data_selection_query\": {\n",
" \"match_all\": {\n",
" }\n",
" },\n",
" \"target_index\": \"planta_ausentismo_transformado_1\",\n",
" \"page_size\": 100,\n",
" \"groups\": [\n",
" {\n",
" \"date_histogram\": {\n",
" \"fixed_interval\": \"1m\",\n",
" \"source_field\": \"PERIODO_PROCESO_CODIGO\",\n",
" \"target_field\": \"PERIODO_PROCESO_CODIGO\",\n",
" \"timezone\": \"UTC\",\n",
" \"format\": \"yyyy-MM-dd'T'HH:mm:ss\"\n",
" }\n",
" },\n",
" {\n",
" \"terms\": {\n",
" \"source_field\": \"CEDULA\",\n",
" \"target_field\": \"CEDULA\"\n",
" }\n",
" },\n",
" {\n",
" \"terms\": {\n",
" \"source_field\": \"AUSENTISMO.TIPO AUSENCIA\",\n",
" \"target_field\": \"TIPO AUSENCIA\"\n",
" }\n",
" }\n",
" ],\n",
" \"aggregations\": {\n",
" \"TOTAL NUMERO DIAS AUSENCIA\": {\n",
" \"sum\": {\n",
" \"field\": \"AUSENTISMO.NUMERO DIAS\"\n",
" }\n",
" },\n",
" \"CANTIDAD AUSENCIAS\": {\n",
" \"value_count\": {\n",
" \"field\": \"AUSENTISMO.NUMERO DIAS\"\n",
" }\n",
" }\n",
" },\n",
" \"continuous\": False\n",
" }\n",
"}\n",
"\n",
"\n",
"data = json.dumps(data)\n",
"\n",
"response = requests.put(url=url, headers=headers, data=data, auth=auth, verify=False)\n",
"response = response.json()\n",
"transform_planta_id = response[\"_id\"]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "31105181-b61b-46fe-8eac-83e000b3916c",
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true
},
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"{'_id': 'planta_ausentismo_transformation',\n",
" '_version': 1,\n",
" '_seq_no': 85358,\n",
" '_primary_term': 9,\n",
" 'transform': {'transform_id': 'planta_ausentismo_transformation',\n",
" 'schema_version': 18,\n",
" 'schedule': {'interval': {'start_time': 1693332367641,\n",
" 'period': 1,\n",
" 'unit': 'Minutes'}},\n",
" 'metadata_id': None,\n",
" 'updated_at': 1693332367641,\n",
" 'enabled': True,\n",
" 'enabled_at': 1693332367641,\n",
" 'description': 'Transformador de Planta y Ausentismo',\n",
" 'source_index': 'planta',\n",
" 'data_selection_query': {'match_all': {'boost': 1.0}},\n",
" 'target_index': 'planta_ausentismo_transformado_1',\n",
" 'page_size': 100,\n",
" 'groups': [{'date_histogram': {'fixed_interval': '1m',\n",
" 'source_field': 'PERIODO_PROCESO_CODIGO',\n",
" 'target_field': 'PERIODO_PROCESO_CODIGO',\n",
" 'timezone': 'UTC',\n",
" 'format': \"yyyy-MM-dd'T'HH:mm:ss\"}},\n",
" {'terms': {'source_field': 'CEDULA', 'target_field': 'CEDULA'}},\n",
" {'terms': {'source_field': 'AUSENTISMO.TIPO AUSENCIA',\n",
" 'target_field': 'TIPO AUSENCIA'}}],\n",
" 'aggregations': {'TOTAL NUMERO DIAS AUSENCIA': {'sum': {'field': 'AUSENTISMO.NUMERO DIAS'}},\n",
" 'CANTIDAD AUSENCIAS': {'value_count': {'field': 'AUSENTISMO.NUMERO DIAS'}}},\n",
" 'continuous': False}}"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"response"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2c518a23-1a06-4da1-b886-f23f9504cf10",
"metadata": {},
"outputs": [],
"source": [
"# NOMBRE_TRANSFORMACION = \"gross_endings_transformation\"\n",
"\n",
"# url = \"https://localhost:9200/_plugins/_transform/\" + NOMBRE_TRANSFORMACION\n",
"# data = {\n",
"# \"transform\": {\n",
"# \"schedule\": {\n",
"# \"interval\": {\n",
"# \"start_time\": 1693329303541,\n",
"# \"period\": 1,\n",
"# \"unit\": \"Minutes\"\n",
"# }\n",
"# },\n",
"# \"enabled\": True,\n",
"# \"description\": \"Transformador de Gross y Endings\",\n",
"# \"source_index\": \"gross\",\n",
"# \"data_selection_query\": {\n",
"# \"match_all\": {\n",
"# }\n",
"# },\n",
"# \"target_index\": \"gros_endings_transformado_1\",\n",
"# \"page_size\": 100,\n",
"# \"groups\": [\n",
"# {\n",
"# \"date_histogram\": {\n",
"# \"fixed_interval\": \"1m\",\n",
"# \"source_field\": \"PERIODO_PROCESO_CODIGO\",\n",
"# \"target_field\": \"PERIODO_PROCESO_CODIGO\",\n",
"# \"timezone\": \"UTC\",\n",
"# \"format\": \"yyyy-MM-dd'T'HH:mm:ss\"\n",
"# }\n",
"# },\n",
"# {\n",
"# \"terms\": {\n",
"# \"source_field\": \"SUBSCRIPTOR_ID\",\n",
"# \"target_field\": \"SUBSCRIPTOR_ID\"\n",
"# }\n",
"# },\n",
"# {\n",
"# \"terms\": {\n",
"# \"source_field\": \"AUSENTISMO.TIPO AUSENCIA\",\n",
"# \"target_field\": \"TIPO AUSENCIA\"\n",
"# }\n",
"# }\n",
"# ],\n",
"# \"aggregations\": {\n",
"# \"TOTAL NUMERO DIAS AUSENCIA\": {\n",
"# \"sum\": {\n",
"# \"field\": \"AUSENTISMO.NUMERO DIAS\"\n",
"# }\n",
"# },\n",
"# \"CANTIDAD AUSENCIAS\": {\n",
"# \"value_count\": {\n",
"# \"field\": \"AUSENTISMO.NUMERO DIAS\"\n",
"# }\n",
"# }\n",
"# },\n",
"# \"continuous\": False\n",
"# }\n",
"# }\n",
"\n",
"\n",
"# data = json.dumps(data)\n",
"\n",
"# response = requests.put(url=url, headers=headers, data=data, auth=auth, verify=False)\n",
"# response = response.json()\n",
"# transform_planta_id = response[\"_id\"]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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