Skip to content

Commit c68b166

Browse files
alephcerosanapolsky
andauthoredSep 13, 2023
Release v0.2.1 (#108)
* Improve dashboard * Dashborad run in to main * Add check config creat dir func * Increase patch version * Add dashborad run --------- Co-authored-by: Sebastian Anapolsky <[email protected]>
1 parent ae4a18c commit c68b166

13 files changed

+74
-43
lines changed
 

‎README_en.md

+2-9
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ according to [Clarification about the concept of lines and branches in urbantrip
165165
```
166166
lineas_contienen_ramales: True
167167
```
168+
168169
Finally, additional useful tables can be specified for the process. On one hand, metadata can be added for the lines, such as their fantasy name in addition to the corresponding id, or to which company they belong. It can identify a line or a line-branch (with branches being small deviations from a main route). In the latter case, `urbantrips` will create two different tables, one for the metadata of the lines and another for the branches.
169170

170171
It also allows the addition of cartographies such as routes, which must be a single 2D Linestring (it does not allow multiline), or different files with spatial units for which data is to be added. For each file, the name of the attribute containing the information must be indicated and, if necessary, an order in which to produce the OD matrices generated by `urbantrips`.
171172

172173
```
173174
nombre_archivo_informacion_lineas: lineas_amba.csv
174-
informacion_lineas_contiene_ramales: True
175175
recorridos_geojson: recorridos_amba.geojson
176176
177177
zonificaciones:
@@ -223,13 +223,7 @@ This is the data schema that `csv` files supplied as inputs to `urbantrips` must
223223
| `nombre_ramal` | str | **Mandatory if lines have branches**. Name of the branch. |
224224
| `empresa` | str | Optional. Name of the company. |
225225
| `descripcion` | str | Optional. Additional description of the line or branch. |
226-
| id_linea | int | **Mandatory**. Integer that identifies the line. |
227-
| nombre_linea | str | **Mandatory**. Name of the line. |
228-
| modo | str | **Mandatory**. Mode of the line. |
229-
| id_ramal | int | Optional. Integer that identifies the branch. |
230-
| nombre_ramal | str | Optional. Name of the branch. |
231-
| empresa | str | Optional. Name of the company. |
232-
| descripcion | str | Optional. Additional description of the line or branch. |
226+
233227

234228

235229
### Lines geoms
@@ -340,7 +334,6 @@ alias_db_insumos: amba
340334
341335
lineas_contienen_ramales: True
342336
nombre_archivo_informacion_lineas: lineas_amba.csv
343-
344337
imputar_destinos_min_distancia: True
345338
346339
#ingresar el nombre de las variables

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name='urbantrips',
11-
version='0.2.0',
11+
version='0.2.1',
1212
author="Felipe Gonzalez & Sebastian Anapolsky",
1313
author_email="",
1414
description="A library to process public transit smart card data.",

‎urbantrips/carto/routes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ def check_route_geoms_columns(geojson_data, branches_present):
227227
"id_ramal vacios en geojson recorridos"
228228
assert not geojson_data.id_ramal.duplicated().any(),\
229229
"id_ramal duplicados en geojson recorridos"
230-
assert geojson_data.dtypes['id_ramal'] == int,\
231-
"id_ramal deben ser int en geojson recorridos"
230+
# assert geojson_data.dtypes['id_ramal'] == int,\
231+
# "id_ramal deben ser int en geojson recorridos"
232232

233233
cols = pd.Series(cols)
234234
columns_ok = cols.isin(geojson_data.columns)

‎urbantrips/dashboard/dashboard.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def get_logo():
145145
"docs", "urbantrips_logo.jpg")
146146
if not os.path.isfile(file_logo):
147147
# URL of the image file on Github
148-
url = 'https://github.com/EL-BID/UrbanTrips/blob/18be313301c979dae5fd27ac5b83f89c76e2dd5f/docs/urbantrips_logo.jpg'
148+
url = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/docs/urbantrips_logo.jpg'
149149

150150
# Send a request to get the content of the image file
151151
response = requests.get(url)

‎urbantrips/dashboard/pages/1_Datos Generales.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def get_logo():
145145
"docs", "urbantrips_logo.jpg")
146146
if not os.path.isfile(file_logo):
147147
# URL of the image file on Github
148-
url = 'https://github.com/EL-BID/UrbanTrips/blob/18be313301c979dae5fd27ac5b83f89c76e2dd5f/docs/urbantrips_logo.jpg'
148+
url = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/docs/urbantrips_logo.jpg'
149149

150150
# Send a request to get the content of the image file
151151
response = requests.get(url)

‎urbantrips/dashboard/pages/2_Indicadores de oferta.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def get_logo():
141141
"docs", "urbantrips_logo.jpg")
142142
if not os.path.isfile(file_logo):
143143
# URL of the image file on Github
144-
url = 'https://github.com/EL-BID/UrbanTrips/blob/18be313301c979dae5fd27ac5b83f89c76e2dd5f/docs/urbantrips_logo.jpg'
144+
url = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/docs/urbantrips_logo.jpg'
145145

146146
# Send a request to get the content of the image file
147147
response = requests.get(url)

‎urbantrips/run_all_urbantrips.py

+6
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22
from urbantrips import process_transactions
33
from urbantrips import run_postprocessing
44
from urbantrips import create_viz
5+
from urbantrips import run_dashboard
56

7+
import warnings
8+
9+
# Filter and suppress specific warnings
10+
warnings.filterwarnings("ignore")
611

712
def main():
813

914
initialize_environment.main()
1015
process_transactions.main()
1116
run_postprocessing.main()
1217
create_viz.main()
18+
run_dashboard.main()
1319

1420
if __name__ == "__main__":
1521
main()

‎urbantrips/run_dashboard.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,20 @@ def download_githubfile(url_file, file_name):
1313
f.write(response.content)
1414
print('copiado: ', file_name)
1515

16+
def main():
17+
18+
os.makedirs('urbantrips/dashboard/pages', exist_ok=True)
19+
download_githubfile(url_file = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/urbantrips/dashboard/dashboard.py',
20+
file_name = 'urbantrips/dashboard/dashboard.py')
21+
download_githubfile(url_file = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/urbantrips/dashboard/pages/1_Datos Generales.py',
22+
file_name = 'urbantrips/dashboard/pages/1_Datos Generales.py')
23+
download_githubfile(url_file = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/urbantrips/dashboard/pages/2_Indicadores de oferta.py',
24+
file_name = 'urbantrips/dashboard/pages/2_Indicadores de oferta.py')
25+
26+
print('')
27+
print('Debe correr desde la terminal streamlit run urbantrips/dashboard/dashboard.py')
28+
print('')
29+
# !streamlit run urbantrips/dashboard/dashboard.py
1630

17-
os.makedirs('urbantrips/dashboard/pages', exist_ok=True)
18-
download_githubfile(url_file = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/urbantrips/dashboard/dashboard.py',
19-
file_name = 'urbantrips/dashboard/dashboard.py')
20-
download_githubfile(url_file = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/urbantrips/dashboard/pages/1_Datos Generales.py',
21-
file_name = 'urbantrips/dashboard/pages/1_Datos Generales.py')
22-
download_githubfile(url_file = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/urbantrips/dashboard/pages/2_Indicadores de oferta.py',
23-
file_name = 'urbantrips/dashboard/pages/2_Colectivos.py.py')
24-
25-
print('')
26-
print('Debe correr desde la terminal streamlit run urbantrips/dashboard/dashboard.py')
27-
print('')
28-
# !streamlit run urbantrips/dashboard/dashboard.py
31+
if __name__ == "__main__":
32+
main()

‎urbantrips/utils/check_configs.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,26 @@ def check_config_errors(config_default):
495495
assert error_txt == '\n', error_txt
496496
print('Se concluyó el chequeo del archivo de configuración')
497497

498+
def check_configs_file():
499+
500+
# Define the directory and file name
501+
directory = 'configs'
502+
file_name = 'configuraciones_generales.yaml'
503+
file_path = os.path.join(directory, file_name)
504+
505+
# Check if the directory exists, and if not, create it
506+
if not os.path.exists(directory):
507+
os.makedirs(directory)
508+
509+
# Check if the YAML file exists, and if not, create it
510+
if not os.path.exists(file_path):
511+
# Create an empty YAML file
512+
with open(file_path, 'w') as file:
513+
yaml.dump({}, file)
514+
515+
print(f"Se creo el archivo '{file_name}' en '{directory}'")
516+
517+
498518
@ duracion
499519
def check_config():
500520
"""
@@ -508,7 +528,7 @@ def check_config():
508528
Returns:
509529
None
510530
"""
511-
531+
check_configs_file()
512532
replace_tabs_with_spaces(os.path.join("configs", "configuraciones_generales.yaml"))
513533
configs = leer_configs_generales()
514534
config_default = revise_configs(configs)

‎urbantrips/utils/utils.py

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ def create_directories():
5353
db_path = os.path.join("resultados", "png")
5454
os.makedirs(db_path, exist_ok=True)
5555

56+
db_path = os.path.join("docs")
57+
os.makedirs(db_path, exist_ok=True)
58+
5659
db_path = os.path.join("resultados", "pdf")
5760
os.makedirs(db_path, exist_ok=True)
5861

‎urbantrips/viz_ppt_utils/viz_ppt_utils.py

+20-15
Original file line numberDiff line numberDiff line change
@@ -164,22 +164,27 @@ def pptx_addpic(prs, slide, img_path, left=0, top=0, width=0, altura_max=0, anc
164164
return slide_return
165165
def get_new_slide(prs, desc_dia_titulo):
166166
## Logo Urbantrips
167-
file_logo = os.path.join(
168-
"docs", "urbantrips_logo.jpg")
169-
if not os.path.isfile(file_logo):
170-
# URL of the image file on Github
171-
url = 'https://github.com/EL-BID/UrbanTrips/blob/18be313301c979dae5fd27ac5b83f89c76e2dd5f/docs/urbantrips_logo.jpg'
172-
173-
# Send a request to get the content of the image file
174-
response = requests.get(url)
175-
176-
# Save the content to a local file
177-
with open(file_logo, 'wb') as f:
178-
f.write(response.content)
179-
180-
slide = pptx_addtitle(prs=prs, slide='', title='', left=0, top=0, width=24, new=True, fontsize=48)
181-
pptx_addpic(prs=prs, slide=slide, img_path=file_logo, left=16, top=12.3, width=8)
167+
try:
168+
db_path = os.path.join("docs")
169+
os.makedirs(db_path, exist_ok=True)
182170

171+
file_logo = os.path.join(
172+
"docs", "urbantrips_logo.jpg")
173+
if not os.path.isfile(file_logo):
174+
# URL of the image file on Github
175+
url = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/docs/urbantrips_logo.jpg'
176+
# Send a request to get the content of the image file
177+
response = requests.get(url)
178+
179+
# Save the content to a local file
180+
with open(file_logo, 'wb') as f:
181+
f.write(response.content)
182+
183+
slide = pptx_addtitle(prs=prs, slide='', title='', left=0, top=0, width=24, new=True, fontsize=48)
184+
pptx_addpic(prs=prs, slide=slide, img_path=file_logo, left=16, top=12.3, width=8)
185+
except:
186+
pass
187+
183188
slide = pptx_addtitle(prs=prs, slide=slide, title='Urbantrips', left=0, top=0, width=24, new=False, fontsize=48)
184189
slide = pptx_addtitle(prs=prs, slide=slide, title=desc_dia_titulo, left=0, top=1, width=24, new=False, fontsize=38)
185190

‎urbantrips_logo.JPG

-14.1 KB
Binary file not shown.

‎urbantrips_logo.PNG

-18.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.