Skip to content

Commit c8160d3

Browse files
committed
update intructions
1 parent 17af536 commit c8160d3

File tree

5 files changed

+103
-56
lines changed

5 files changed

+103
-56
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/devcontainers/python:0-3.10
1+
FROM mcr.microsoft.com/devcontainers/python:0-3.11
22

33
ENV PYTHONUNBUFFERED 1
44

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
DATABASE_URL=postgresql://gitpod@localhost:5432/example
1+
DATABASE_URL=postgresql://gitpod@localhost:5432/sample-db

README.es.md

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,28 @@ Esta plantilla está diseñada para impulsar proyectos de ciencia de datos propo
66

77
El proyecto está organizado de la siguiente manera:
88

9-
- `app.py` - El script principal de Python que ejecutas para tu proyecto.
10-
- `explore.py` - Un notebook para que puedas hacer tus exploraciones, idealmente el codigo de este notebook se migra hacia app.py para subir a produccion.
11-
- `utils.py` - Este archivo contiene código de utilidad para operaciones como conexiones de base de datos.
12-
- `requirements.txt` - Este archivo contiene la lista de paquetes de Python necesarios.
13-
- `models/` - Este directorio debería contener tus clases de modelos SQLAlchemy.
14-
- `data/` - Este directorio contiene los siguientes subdirectorios:
15-
- `interim/` - Para datos intermedios que han sido transformados.
16-
- `processed/` - Para los datos finales a utilizar para el modelado.
17-
- `raw/` - Para datos brutos sin ningún procesamiento.
18-
19-
## Configuración
9+
- **`src/app.py`** → Script principal de Python donde correrá tu proyecto.
10+
- **`src/explore.ipynb`** → Notebook para exploración y pruebas. Una vez finalizada la exploración, migra el código limpio a `app.py`.
11+
- **`src/utils.py`** → Funciones auxiliares, como conexión a bases de datos.
12+
- **`requirements.txt`** → Lista de paquetes de Python necesarios.
13+
- **`models/`** → Contendrá tus clases de modelos SQLAlchemy.
14+
- **`data/`** → Almacena los datasets en diferentes etapas:
15+
- **`data/raw/`** → Datos sin procesar.
16+
- **`data/interim/`** → Datos transformados temporalmente.
17+
- **`data/processed/`** → Datos listos para análisis.
18+
19+
20+
## ⚡ Configuración Inicial en Codespaces (Recomendado)
21+
22+
No es necesario realizar ninguna configuración manual, ya que **Codespaces se configura automáticamente** con los archivos predefinidos que ha creado la academia para ti. Simplemente sigue estos pasos:
23+
24+
1. **Espera a que el entorno se configure automáticamente**.
25+
- Todos los paquetes necesarios y la base de datos se instalarán por sí mismos.
26+
- El `username` y `db_name` creados automáticamente están en el archivo **`.env`** en la raíz del proyecto.
27+
2. **Una vez que Codespaces esté listo, puedes comenzar a trabajar inmediatamente**.
28+
29+
30+
## 💻 Configuración en Local (Solo si no puedes usar Codespaces)
2031

2132
**Prerrequisitos**
2233

@@ -34,9 +45,19 @@ pip install -r requirements.txt
3445

3546
**Crear una base de datos (si es necesario)**
3647

37-
Crea una nueva base de datos dentro del motor Postgres personalizando y ejecutando el siguiente comando: `$ createdb -h localhost -U <username> <db_name>`
38-
Conéctate al motor Postgres para usar tu base de datos, manipular tablas y datos: `$ psql -h localhost -U <username> <db_name>`
39-
NOTA: Recuerda revisar la información del archivo ./.env para obtener el nombre de usuario y db_name.
48+
Crea una nueva base de datos dentro del motor Postgres personalizando y ejecutando el siguiente comando:
49+
50+
```bash
51+
$ psql -U postgres -c "DO \$\$ BEGIN
52+
CREATE USER mi_usuario WITH PASSWORD 'mi_contraseña';
53+
CREATE DATABASE mi_base_de_datos OWNER mi_usuario;
54+
END \$\$;"
55+
```
56+
Conéctate al motor Postgres para usar tu base de datos, manipular tablas y datos:
57+
58+
```bash
59+
$ psql -U mi_usuario -d mi_base_de_datos
60+
```
4061

4162
¡Una vez que estés dentro de PSQL podrás crear tablas, hacer consultas, insertar, actualizar o eliminar datos y mucho más!
4263

@@ -45,15 +66,18 @@ NOTA: Recuerda revisar la información del archivo ./.env para obtener el nombre
4566
Crea un archivo .env en el directorio raíz del proyecto para almacenar tus variables de entorno, como tu cadena de conexión a la base de datos:
4667

4768
```makefile
48-
DATABASE_URL="your_database_connection_url_here"
69+
DATABASE_URL="postgresql://<USUARIO>:<CONTRASEÑA>@<HOST>:<PUERTO>/<NOMBRE_BD>"
70+
71+
#example
72+
DATABASE_URL="postgresql://mi_usuario:mi_contraseña@localhost:5432/mi_base_de_datos"
4973
```
5074

5175
## Ejecutando la Aplicación
5276

5377
Para ejecutar la aplicación, ejecuta el script app.py desde la raíz del directorio del proyecto:
5478

5579
```bash
56-
python app.py
80+
python src/app.py
5781
```
5882

5983
## Añadiendo Modelos
@@ -63,16 +87,16 @@ Para añadir clases de modelos SQLAlchemy, crea nuevos archivos de script de Pyt
6387
Definición del modelo de ejemplo (`models/example_model.py`):
6488

6589
```py
66-
from sqlalchemy.ext.declarative import declarative_base
67-
from sqlalchemy import Column, Integer, String
90+
from sqlalchemy.orm import DeclarativeBase
91+
from sqlalchemy import String
92+
from sqlalchemy.orm import Mapped, mapped_column
6893

6994
Base = declarative_base()
7095

7196
class ExampleModel(Base):
7297
__tablename__ = 'example_table'
73-
id = Column(Integer, primary_key=True)
74-
name = Column(String)
75-
98+
id: Mapped[int] = mapped_column(primary_key=True)
99+
username: Mapped[str] = mapped_column(unique=True)
76100
```
77101

78102
## Trabajando con Datos

README.md

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,32 @@ This boilerplate is designed to kickstart data science projects by providing a b
66

77
The project is organized as follows:
88

9-
- `app.py` - The main Python script that you run for your project.
10-
- `explore.py` - A notebook to explore data, play around, visualize, clean, etc. Ideally the notebook code should be migrated to the app.py when moving to production.
11-
- `utils.py` - This file contains utility code for operations like database connections.
12-
- `requirements.txt` - This file contains the list of necessary python packages.
13-
- `models/` - This directory should contain your SQLAlchemy model classes.
14-
- `data/` - This directory contains the following subdirectories:
15-
- `interin/` - For intermediate data that has been transformed.
16-
- `processed/` - For the final data to be used for modeling.
17-
- `raw/` - For raw data without any processing.
18-
19-
20-
## Setup
9+
- **`src/app.py`** → Main Python script where your project will run.
10+
- **`src/explore.ipynb`** → Notebook for exploration and testing. Once exploration is complete, migrate the clean code to `app.py`.
11+
- **`src/utils.py`** → Auxiliary functions, such as database connection.
12+
- **`requirements.txt`** → List of required Python packages.
13+
- **`models/`** → Will contain your SQLAlchemy model classes.
14+
- **`data/`** → Stores datasets at different stages:
15+
- **`data/raw/`** → Raw data.
16+
- **`data/interim/`** → Temporarily transformed data.
17+
- **`data/processed/`** → Data ready for analysis.
18+
19+
20+
## ⚡ Initial Setup in Codespaces (Recommended)
21+
22+
No manual setup is required, as **Codespaces is automatically configured** with the predefined files created by the academy for you. Just follow these steps:
23+
24+
1. **Wait for the environment to configure automatically**.
25+
- All necessary packages and the database will install themselves.
26+
- The automatically created `username` and `db_name` are in the **`.env`** file at the root of the project.
27+
2. **Once Codespaces is ready, you can start working immediately**.
28+
29+
30+
## 💻 Local Setup (Only if you can't use Codespaces)
2131

2232
**Prerequisites**
2333

24-
Make sure you have Python 3.11+ installed on your. You will also need pip for installing the Python packages.
34+
Make sure you have Python 3.11+ installed on your machine. You will also need pip to install the Python packages.
2535

2636
**Installation**
2737

@@ -33,57 +43,70 @@ Navigate to the project directory and install the required Python packages:
3343
pip install -r requirements.txt
3444
```
3545

36-
**Create a database (if needed)**
46+
**Create a database (if necessary)**
47+
48+
Create a new database within the Postgres engine by customizing and executing the following command:
3749

38-
Create a new database within the Postgres engine by customizing and executing the following command: `$ createdb -h localhost -U <username> <db_name>`
39-
Connect to the Postgres engine to use your database, manipulate tables and data: `$ psql -h localhost -U <username> <db_name>`
40-
NOTE: Remember to check the ./.env file information to get the username and db_name.
50+
```bash
51+
$ psql -U postgres -c "DO \$\$ BEGIN
52+
CREATE USER my_user WITH PASSWORD 'my_password';
53+
CREATE DATABASE my_database OWNER my_user;
54+
END \$\$;"
55+
```
56+
Connect to the Postgres engine to use your database, manipulate tables, and data:
4157

42-
Once you are inside PSQL you will be able to create tables, make queries, insert, update or delete data and much more!
58+
```bash
59+
$ psql -U my_user -d my_database
60+
```
61+
62+
Once inside PSQL, you can create tables, run queries, insert, update, or delete data, and much more!
4363

4464
**Environment Variables**
4565

46-
Create a .env file in the project root directory to store your environment variables, such as your database connection string:
66+
Create a .env file in the root directory of the project to store your environment variables, such as your database connection string:
4767

4868
```makefile
49-
DATABASE_URL="your_database_connection_url_here"
69+
DATABASE_URL="postgresql://<USER>:<PASSWORD>@<HOST>:<PORT>/<DB_NAME>"
70+
71+
#example
72+
DATABASE_URL="postgresql://my_user:my_password@localhost:5432/my_database"
5073
```
5174

5275
## Running the Application
5376

54-
To run the application, execute the app.py script from the root of the project directory:
77+
To run the application, execute the app.py script from the root directory of the project:
5578

5679
```bash
57-
python app.py
80+
python src/app.py
5881
```
5982

6083
## Adding Models
6184

62-
To add SQLAlchemy model classes, create new Python script files inside the models/ directory. These classes should be defined according to your database schema.
85+
To add SQLAlchemy model classes, create new Python script files within the models/ directory. These classes should be defined according to your database schema.
6386

6487
Example model definition (`models/example_model.py`):
6588

6689
```py
67-
from sqlalchemy.ext.declarative import declarative_base
68-
from sqlalchemy import Column, Integer, String
90+
from sqlalchemy.orm import declarative_base
91+
from sqlalchemy import String
92+
from sqlalchemy.orm import Mapped, mapped_column
6993

7094
Base = declarative_base()
7195

7296
class ExampleModel(Base):
7397
__tablename__ = 'example_table'
74-
id = Column(Integer, primary_key=True)
75-
name = Column(String)
76-
98+
id: Mapped[int] = mapped_column(primary_key=True)
99+
username: Mapped[str] = mapped_column(unique=True)
77100
```
78101

79102
## Working with Data
80103

81-
You can place your raw datasets in the data/raw directory, intermediate datasets in data/interim, and the processed datasets ready for analysis in data/processed.
104+
You can place your raw datasets in the data/raw directory, intermediate datasets in data/interim, and processed datasets ready for analysis in data/processed.
82105

83-
To process data, you can modify the app.py script to include your data processing steps, utilizing pandas for data manipulation and analysis.
106+
To process data, you can modify the app.py script to include your data processing steps, using pandas for data manipulation and analysis.
84107

85108
## Contributors
86109

87-
This template was built as part of the 4Geeks Academy [Data Science and Machine Learning Bootcamp](https://4geeksacademy.com/us/coding-bootcamps/datascience-machine-learning) by [Alejandro Sanchez](https://twitter.com/alesanchezr) and many other contributors. Find out more about [4Geeks Academy's BootCamp programs](https://4geeksacademy.com/us/programs) here.
110+
This template was built as part of the [Data Science and Machine Learning Bootcamp](https://4geeksacademy.com/us/coding-bootcamps/datascience-machine-learning) by 4Geeks Academy by [Alejandro Sanchez](https://twitter.com/alesanchezr) and many other contributors. Learn more about [4Geeks Academy BootCamp programs](https://4geeksacademy.com/us/programs) here.
88111

89-
Other templates and resources like this can be found on the school GitHub page.
112+
Other templates and resources like this can be found on the school's GitHub page.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ python-dotenv>=0.20.0
1010
requests>=2.27.1
1111
scikit-learn
1212
seaborn>=0.12.2
13-
sqlalchemy>=1.4.37
13+
sqlalchemy>=2.0.38
1414
sympy>=1.10.1
1515
xgboost

0 commit comments

Comments
 (0)