Skip to content

Commit

Permalink
Release v0.2.1 (#108)
Browse files Browse the repository at this point in the history

* 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]>
  • Loading branch information
alephcero and sanapolsky authored Sep 13, 2023
1 parent ae4a18c commit c68b166
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 43 deletions.
11 changes: 2 additions & 9 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ according to [Clarification about the concept of lines and branches in urbantrip
```
lineas_contienen_ramales: True
```

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.

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`.

```
nombre_archivo_informacion_lineas: lineas_amba.csv
informacion_lineas_contiene_ramales: True
recorridos_geojson: recorridos_amba.geojson
zonificaciones:
Expand Down Expand Up @@ -223,13 +223,7 @@ This is the data schema that `csv` files supplied as inputs to `urbantrips` must
| `nombre_ramal` | str | **Mandatory if lines have branches**. Name of the branch. |
| `empresa` | str | Optional. Name of the company. |
| `descripcion` | str | Optional. Additional description of the line or branch. |
| id_linea | int | **Mandatory**. Integer that identifies the line. |
| nombre_linea | str | **Mandatory**. Name of the line. |
| modo | str | **Mandatory**. Mode of the line. |
| id_ramal | int | Optional. Integer that identifies the branch. |
| nombre_ramal | str | Optional. Name of the branch. |
| empresa | str | Optional. Name of the company. |
| descripcion | str | Optional. Additional description of the line or branch. |



### Lines geoms
Expand Down Expand Up @@ -340,7 +334,6 @@ alias_db_insumos: amba
lineas_contienen_ramales: True
nombre_archivo_informacion_lineas: lineas_amba.csv
imputar_destinos_min_distancia: True
#ingresar el nombre de las variables
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name='urbantrips',
version='0.2.0',
version='0.2.1',
author="Felipe Gonzalez & Sebastian Anapolsky",
author_email="",
description="A library to process public transit smart card data.",
Expand Down
4 changes: 2 additions & 2 deletions urbantrips/carto/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ def check_route_geoms_columns(geojson_data, branches_present):
"id_ramal vacios en geojson recorridos"
assert not geojson_data.id_ramal.duplicated().any(),\
"id_ramal duplicados en geojson recorridos"
assert geojson_data.dtypes['id_ramal'] == int,\
"id_ramal deben ser int en geojson recorridos"
# assert geojson_data.dtypes['id_ramal'] == int,\
# "id_ramal deben ser int en geojson recorridos"

cols = pd.Series(cols)
columns_ok = cols.isin(geojson_data.columns)
Expand Down
2 changes: 1 addition & 1 deletion urbantrips/dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get_logo():
"docs", "urbantrips_logo.jpg")
if not os.path.isfile(file_logo):
# URL of the image file on Github
url = 'https://github.com/EL-BID/UrbanTrips/blob/18be313301c979dae5fd27ac5b83f89c76e2dd5f/docs/urbantrips_logo.jpg'
url = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/docs/urbantrips_logo.jpg'

# Send a request to get the content of the image file
response = requests.get(url)
Expand Down
2 changes: 1 addition & 1 deletion urbantrips/dashboard/pages/1_Datos Generales.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get_logo():
"docs", "urbantrips_logo.jpg")
if not os.path.isfile(file_logo):
# URL of the image file on Github
url = 'https://github.com/EL-BID/UrbanTrips/blob/18be313301c979dae5fd27ac5b83f89c76e2dd5f/docs/urbantrips_logo.jpg'
url = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/docs/urbantrips_logo.jpg'

# Send a request to get the content of the image file
response = requests.get(url)
Expand Down
2 changes: 1 addition & 1 deletion urbantrips/dashboard/pages/2_Indicadores de oferta.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def get_logo():
"docs", "urbantrips_logo.jpg")
if not os.path.isfile(file_logo):
# URL of the image file on Github
url = 'https://github.com/EL-BID/UrbanTrips/blob/18be313301c979dae5fd27ac5b83f89c76e2dd5f/docs/urbantrips_logo.jpg'
url = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/docs/urbantrips_logo.jpg'

# Send a request to get the content of the image file
response = requests.get(url)
Expand Down
6 changes: 6 additions & 0 deletions urbantrips/run_all_urbantrips.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
from urbantrips import process_transactions
from urbantrips import run_postprocessing
from urbantrips import create_viz
from urbantrips import run_dashboard

import warnings

# Filter and suppress specific warnings
warnings.filterwarnings("ignore")

def main():

initialize_environment.main()
process_transactions.main()
run_postprocessing.main()
create_viz.main()
run_dashboard.main()

if __name__ == "__main__":
main()
28 changes: 16 additions & 12 deletions urbantrips/run_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ def download_githubfile(url_file, file_name):
f.write(response.content)
print('copiado: ', file_name)

def main():

os.makedirs('urbantrips/dashboard/pages', exist_ok=True)
download_githubfile(url_file = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/urbantrips/dashboard/dashboard.py',
file_name = 'urbantrips/dashboard/dashboard.py')
download_githubfile(url_file = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/urbantrips/dashboard/pages/1_Datos Generales.py',
file_name = 'urbantrips/dashboard/pages/1_Datos Generales.py')
download_githubfile(url_file = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/urbantrips/dashboard/pages/2_Indicadores de oferta.py',
file_name = 'urbantrips/dashboard/pages/2_Indicadores de oferta.py')

print('')
print('Debe correr desde la terminal streamlit run urbantrips/dashboard/dashboard.py')
print('')
# !streamlit run urbantrips/dashboard/dashboard.py

os.makedirs('urbantrips/dashboard/pages', exist_ok=True)
download_githubfile(url_file = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/urbantrips/dashboard/dashboard.py',
file_name = 'urbantrips/dashboard/dashboard.py')
download_githubfile(url_file = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/urbantrips/dashboard/pages/1_Datos Generales.py',
file_name = 'urbantrips/dashboard/pages/1_Datos Generales.py')
download_githubfile(url_file = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/urbantrips/dashboard/pages/2_Indicadores de oferta.py',
file_name = 'urbantrips/dashboard/pages/2_Colectivos.py.py')

print('')
print('Debe correr desde la terminal streamlit run urbantrips/dashboard/dashboard.py')
print('')
# !streamlit run urbantrips/dashboard/dashboard.py
if __name__ == "__main__":
main()
22 changes: 21 additions & 1 deletion urbantrips/utils/check_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,26 @@ def check_config_errors(config_default):
assert error_txt == '\n', error_txt
print('Se concluyó el chequeo del archivo de configuración')

def check_configs_file():

# Define the directory and file name
directory = 'configs'
file_name = 'configuraciones_generales.yaml'
file_path = os.path.join(directory, file_name)

# Check if the directory exists, and if not, create it
if not os.path.exists(directory):
os.makedirs(directory)

# Check if the YAML file exists, and if not, create it
if not os.path.exists(file_path):
# Create an empty YAML file
with open(file_path, 'w') as file:
yaml.dump({}, file)

print(f"Se creo el archivo '{file_name}' en '{directory}'")


@ duracion
def check_config():
"""
Expand All @@ -508,7 +528,7 @@ def check_config():
Returns:
None
"""

check_configs_file()
replace_tabs_with_spaces(os.path.join("configs", "configuraciones_generales.yaml"))
configs = leer_configs_generales()
config_default = revise_configs(configs)
Expand Down
3 changes: 3 additions & 0 deletions urbantrips/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def create_directories():
db_path = os.path.join("resultados", "png")
os.makedirs(db_path, exist_ok=True)

db_path = os.path.join("docs")
os.makedirs(db_path, exist_ok=True)

db_path = os.path.join("resultados", "pdf")
os.makedirs(db_path, exist_ok=True)

Expand Down
35 changes: 20 additions & 15 deletions urbantrips/viz_ppt_utils/viz_ppt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,27 @@ def pptx_addpic(prs, slide, img_path, left=0, top=0, width=0, altura_max=0, anc
return slide_return
def get_new_slide(prs, desc_dia_titulo):
## Logo Urbantrips
file_logo = os.path.join(
"docs", "urbantrips_logo.jpg")
if not os.path.isfile(file_logo):
# URL of the image file on Github
url = 'https://github.com/EL-BID/UrbanTrips/blob/18be313301c979dae5fd27ac5b83f89c76e2dd5f/docs/urbantrips_logo.jpg'

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

# Save the content to a local file
with open(file_logo, 'wb') as f:
f.write(response.content)

slide = pptx_addtitle(prs=prs, slide='', title='', left=0, top=0, width=24, new=True, fontsize=48)
pptx_addpic(prs=prs, slide=slide, img_path=file_logo, left=16, top=12.3, width=8)
try:
db_path = os.path.join("docs")
os.makedirs(db_path, exist_ok=True)

file_logo = os.path.join(
"docs", "urbantrips_logo.jpg")
if not os.path.isfile(file_logo):
# URL of the image file on Github
url = 'https://raw.githubusercontent.com/EL-BID/UrbanTrips/dev/docs/urbantrips_logo.jpg'
# Send a request to get the content of the image file
response = requests.get(url)

# Save the content to a local file
with open(file_logo, 'wb') as f:
f.write(response.content)

slide = pptx_addtitle(prs=prs, slide='', title='', left=0, top=0, width=24, new=True, fontsize=48)
pptx_addpic(prs=prs, slide=slide, img_path=file_logo, left=16, top=12.3, width=8)
except:
pass

slide = pptx_addtitle(prs=prs, slide=slide, title='Urbantrips', left=0, top=0, width=24, new=False, fontsize=48)
slide = pptx_addtitle(prs=prs, slide=slide, title=desc_dia_titulo, left=0, top=1, width=24, new=False, fontsize=38)

Expand Down
Binary file removed urbantrips_logo.JPG
Binary file not shown.
Binary file removed urbantrips_logo.PNG
Binary file not shown.

0 comments on commit c68b166

Please sign in to comment.