File tree 7 files changed +220
-223
lines changed
7 files changed +220
-223
lines changed Original file line number Diff line number Diff line change 2
2
3
3
4
4
def logFileName (file : str ) -> str :
5
- current_dir = os .path .dirname (os .path .relpath (__file__ ))
5
+ current_dir = os .path .dirname (os .path .relpath (file ))
6
6
WORK_DIR = current_dir .split ("/" )[- 1 :][0 ]
7
7
return WORK_DIR
Original file line number Diff line number Diff line change 1
1
from etl .models .extract .ApiToParquetFile import extraction
2
- from etl .config .logFile import logFileName
3
-
4
- mdName = logFileName (file = __file__ )
5
2
6
3
7
4
class ExecutePipeline :
Original file line number Diff line number Diff line change 1
- import random
1
+ import time
2
2
3
+ start = time .time ()
4
+ import random
3
5
import requests
4
6
5
7
from etl .controller .pipeline import ExecutePipeline
@@ -24,3 +26,5 @@ def GenerateRandomParams(ParamsQty: int) -> list:
24
26
25
27
if __name__ == "__main__" :
26
28
NewExec = ExecutePipeline (* GenerateRandomParams (1 ))
29
+
30
+ print ("Tempo decorrido: " , time .time () - start , "segundos" )
Original file line number Diff line number Diff line change 9
9
from tqdm import tqdm
10
10
11
11
# Imports de Módulos Internos
12
- from etl .models .extract import (
13
- loggingInfo ,
14
- loggingWarn ,
15
- DefaultOutputFolder ,
12
+ from etl .common .utils .logs import loggingInfo , loggingWarn
13
+ from etl .common .utils .common import (
16
14
DefaultTimestampStr ,
15
+ DefaultOutputFolder ,
17
16
DefaultUTCDatetime ,
18
17
)
19
18
from etl .config .logFile import logFileName
@@ -63,7 +62,8 @@ def PipelineRun(self, ValidParams: list) -> list:
63
62
else :
64
63
if tryNumber < API .RETRY_ATTEMPTS - 1 :
65
64
loggingWarn (
66
- f"response error, status_code { response .status_code } . Retrying in { API .RETRY_TIME_SECONDS } seconds..." ,
65
+ f"""response error, status_code { response .status_code } .
66
+ Retrying in { API .RETRY_TIME_SECONDS } seconds...""" ,
67
67
WORK_DIR ,
68
68
)
69
69
for _ in tqdm (range (100 ), total = 100 , desc = f"loading" ):
@@ -75,7 +75,9 @@ def PipelineRun(self, ValidParams: list) -> list:
75
75
else :
76
76
loggingWarn ("Attempt limits exceeded" , WORK_DIR )
77
77
raise ConnectionError (
78
- f"Could not connect to the server after 3 attempts. Please try again later. Response status code: { response .status_code } "
78
+ f"""Could not connect to the server after 3 attempts.
79
+ Please try again later.
80
+ Response status code: { response .status_code } """
79
81
)
80
82
81
83
output_path = DefaultOutputFolder ()
Original file line number Diff line number Diff line change 1
1
import requests
2
- import os
3
- from dotenv import load_dotenv
4
2
from etl .common .utils .logs import loggingWarn
3
+ from etl .config .datasource import API
4
+ from etl .config .logFile import logFileName
5
5
6
- mdName = "extract"
7
-
8
- load_dotenv ()
9
-
10
- SRV_URL = str (os .getenv ("SERVER_URL" ))
11
- """ Reference for Server URL from enviroment variable """
6
+ WORK_DIR = logFileName (file = __file__ )
12
7
13
8
14
9
class ParamsValidator :
@@ -25,17 +20,17 @@ def __ValidParamsForCall__(self) -> list:
25
20
26
21
"""
27
22
valParams = []
28
- AvaliableList = requests .get (SRV_URL + "/json/available" ).json ()
23
+ AvaliableList = requests .get (API . ENDPOINT_AVALIABLE_PARITIES ).json ()
29
24
30
25
for param in self .params :
31
26
if param in AvaliableList :
32
27
valParams .append (param )
33
28
else :
34
- loggingWarn (f"Param: { param } is not valid for call" , mdName )
29
+ loggingWarn (f"Param: { param } is not valid for call" , WORK_DIR )
35
30
36
31
if valParams :
37
32
return valParams
38
33
else :
39
34
raise KeyError (
40
- f"The informed params: { self .params } are not avaliable for extract, see available list in: { SRV_URL + '/json/available' } "
35
+ f"The informed params: { self .params } are not avaliable for extract, see available list in: { API . ENDPOINT_AVALIABLE_PARITIES } "
41
36
)
Original file line number Diff line number Diff line change 1
- # Custom Logs
2
- from etl .common .utils .logs import loggingInfo , loggingError , loggingWarn
3
- from etl .common .utils .common import (
4
- DefaultTimestampStr ,
5
- DefaultOutputFolder ,
6
- DefaultUTCDatetime ,
7
- )
You can’t perform that action at this time.
0 commit comments