Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ed42106
feat: add fastapi package
Jun 3, 2024
3142423
feat: docker add load-data script and volume persistence
Jun 3, 2024
f0cefac
feat: add ports & ports/{id} endpoints
Jun 3, 2024
a97e665
feat: api add endpoint /zones/by-category/{category}
Jun 7, 2024
7ccc3f1
feat: ajout endpoint /zones/all/categories pour avoir la liste des ca…
Jun 7, 2024
3730045
feat: add endpoint /zones/by-category/{cat|all}/by-sub-category/{sub}
Jun 7, 2024
d1559d8
Corrections de types
njouanin Jun 8, 2024
4ea40be
MAJ poetry.lock
njouanin Jun 10, 2024
d5d116a
wip => removed file in main
SaboniAmine Jun 10, 2024
902f993
wip2
SaboniAmine Jul 6, 2024
0bd92aa
add requirements
SaboniAmine Jul 6, 2024
d90a3c7
move main file
SaboniAmine Jul 6, 2024
884a990
change cronjob definition
SaboniAmine Jul 6, 2024
5728e17
add init.py files
SaboniAmine Jul 6, 2024
8af264c
add init.py files
SaboniAmine Jul 6, 2024
698cdde
switch loader place
SaboniAmine Jul 6, 2024
1c9d7f9
fix cronjob
SaboniAmine Jul 6, 2024
97a451a
add config file path to config for cronjob
SaboniAmine Jul 7, 2024
86659de
fix cronjob planning back
SaboniAmine Jul 7, 2024
bcf7604
#528: switch API hostname + log API hostname
marthevienne Mar 23, 2026
6475f6b
#528: update logs | connection to Kpler hostname
marthevienne Mar 24, 2026
4779438
Merge branch 'quick-fix-api-hostname-kpler' into up-to-date-main-crawler
marthevienne Apr 2, 2026
874c63d
fix: harmonize container UseCases class name across app
marthevienne Apr 2, 2026
4131302
quick-fix: update root name CC instance
marthevienne Apr 2, 2026
c909999
quick-fix: lower default api_pooling_period
marthevienne Apr 2, 2026
d65036a
fix: manual corrections to reach main state
marthevienne Apr 3, 2026
f1e48b0
fix: manual corrections to reach main state
marthevienne Apr 3, 2026
5a1fdee
Merge branch 'up-to-date-main-crawler' of https://github.com/dataforg…
marthevienne Apr 3, 2026
3d689d4
Merge branch 'up-to-date-main-crawler' of https://github.com/dataforg…
marthevienne Apr 3, 2026
c70c2d6
Merge branch 'up-to-date-main-crawler' of https://github.com/dataforg…
marthevienne Apr 3, 2026
efe1cd5
remove cronjobs for dev purposes
marthevienne Apr 3, 2026
58d20ea
remove computed requirements.txt
marthevienne Apr 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added backend/bloom/__init__.py
Empty file.
51 changes: 22 additions & 29 deletions backend/bloom/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@
from pathlib import Path
from datetime import timedelta
from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import Any

from pydantic import (
AliasChoices,
AmqpDsn,
BaseModel,
Field,
ImportString,
PostgresDsn,
RedisDsn,
field_validator,
model_validator
)


class Settings(BaseSettings):

model_config = SettingsConfigDict(
Expand All @@ -28,30 +21,30 @@ class Settings(BaseSettings):
env_ignore_empty=True,
env_nested_delimiter='__',
env_file='.env',
env_file_encoding = 'utf-8',
env_file_encoding='utf-8',
extra='ignore'
)
)

# Déclaration des attributs/paramètres disponibles au sein de la class settings
postgres_user:str = Field(default='')
postgres_password:str = Field(default='')
postgres_hostname:str = Field(min_length=1,
default='localhost')
postgres_port:int = Field(gt=1024,
default=5432)
postgres_user: str = Field(default='')
postgres_password: str = Field(default='')
postgres_hostname: str = Field(min_length=1,
default='localhost')
postgres_port: int = Field(gt=1024,
default=5432)

postgres_db:str = Field(min_length=1,max_length=32,pattern=r'^(?:[a-zA-Z]|_)[\w\d_]*$')
postgres_db: str = Field(min_length=1, max_length=32, pattern=r'^(?:[a-zA-Z]|_)[\w\d_]*$')
srid: int = Field(default=4326)
spire_token:str = Field(default='')
data_folder:str=Field(default=str(Path(__file__).parent.parent.parent.joinpath('./data')))
db_url:str=Field(default='')
spire_token: str = Field(default='')
data_folder: str = Field(default=str(Path(__file__).parent.parent.parent.joinpath('./data')))
db_url: str = Field(default='')

redis_host: str = Field(default='localhost')
redis_port: int = Field(default=6379)
redis_password: str = Field(default='bloom',min_length=1)
redis_cache_expiration: int = Field(default=900)

api_pooling_period: timedelta = Field(default=timedelta(minutes=15))
api_pooling_period: timedelta = Field(default=timedelta(minutes=2))

logging_level:str=Field(
default="INFO",
Expand All @@ -60,15 +53,15 @@ class Settings(BaseSettings):
api_key:str = Field(min_length=4,default='bloom')

@model_validator(mode='after')
def update_db_url(self)->dict:
new_url= f"postgresql://{self.postgres_user}:"\
f"{self.postgres_password}@{self.postgres_hostname}:"\
f"{self.postgres_port}/{self.postgres_db}"
def update_db_url(self) -> dict:
new_url = f"postgresql://{self.postgres_user}:" \
f"{self.postgres_password}@{self.postgres_hostname}:" \
f"{self.postgres_port}/{self.postgres_db}"
if self.db_url != new_url:
self.db_url = new_url
self.db_url = new_url
return self

settings = Settings(_env_file=os.getenv('BLOOM_CONFIG',
Path(__file__).parent.parent.parent.joinpath('.env')),
Path(__file__).parent.parent.parent.joinpath('.env')),
_secrets_dir=os.getenv('BLOOM_SECRETS_DIR',
Path(__file__).parent.parent.parent.joinpath('./secrets')))
Path(__file__).parent.parent.parent.joinpath('./secrets')))
19 changes: 10 additions & 9 deletions backend/bloom/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ class UseCases(containers.DeclarativeContainer):
session_factory=db.provided.session,
)

get_spire_data_usecase = providers.Factory(GetVesselsFromSpire)

generate_alert_usecase = providers.Factory(
GenerateAlerts,
alert_repository=alert_repository,
raster_repository=raster_repository,
)

spire_ais_data_repository = providers.Factory(
SpireAisDataRepository,
session_factory=db.provided.session,
Expand All @@ -95,4 +87,13 @@ class UseCases(containers.DeclarativeContainer):
metrics_repository = providers.Factory(
MetricsRepository,
session_factory=db.provided.session,
)
)
get_spire_data_usecase = providers.Factory(
GetVesselsFromSpire
)

generate_alert_usecase = providers.Factory(
GenerateAlerts,
alert_repository=alert_repository,
raster_repository=raster_repository,
)
Empty file.
Empty file.
Empty file.
Empty file.
14 changes: 14 additions & 0 deletions backend/bloom/infra/repositories/repository_zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ def get_all_zones_summary(self, session: Session) -> list[ZoneSummary]:
return []
return [ZoneRepository.map_to_summary(entity) for entity in q]

def get_all_zone_categories(self, session: Session) -> list[ZoneCategory]:
q = session.query(sql_model.Zone.category,
sql_model.Zone.sub_category).distinct()
q=session.execute(q)
if not q:
return []
return [ZoneRepository.map_to_domain(ZoneCategory(category=cat,sub_category=sub)) for cat,sub in q]

def get_all_zone_categories(self, session: Session) -> list[ZoneCategory]:
q = session.query(sql_model.Zone.category,
sql_model.Zone.sub_category).distinct()
Expand Down Expand Up @@ -123,6 +131,12 @@ def map_to_summary(zone: sql_model.Zone) -> ZoneSummary:
created_at=zone.created_at,
enable=zone.enable,
)
@staticmethod
def map_to_domain(category: ZoneCategory) -> ZoneCategory:
return ZoneCategory(
category=category.category,
sub_category=category.sub_category
)

@staticmethod
def map_zonecategory_to_domain(category: ZoneCategory) -> ZoneCategory:
Expand Down
Empty file.
1 change: 1 addition & 0 deletions backend/bloom/services/GetVesselsFromSpire.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self) -> None:
)

def create_client(self) -> Client:
logger.info(f"Connecting to {self.transport.url}...")
try:
client = Client(transport=self.transport, fetch_schema_from_transport=True)
except exceptions.ConnectTimeout:
Expand Down
Empty file added backend/bloom/tasks/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion backend/bloom/tasks/load_dim_zone_amp_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def map_to_domain(row: pd.Series) -> Zone:
)


def run():
def run(csv_file_name: str):
use_cases = UseCases()
db = use_cases.db()
zone_repository = use_cases.zone_repository()
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def run(dump_path: str) -> None:
)
args = parser.parse_args()
time_start = perf_counter()
logger.info("DEBUT - Chargement des données JSON depuis l'API SPIRE")
logger.info("DEBUT - Chargement des données JSON depuis l'API Kpler")
run(args.dump_path)
time_end = perf_counter()
duration = time_end - time_start
logger.info(f"FIN - Chargement des données depuis l'API SPIRE en {duration:.2f}s")
logger.info(f"FIN - Chargement des données depuis l'API Kpler en {duration:.2f}s")
3 changes: 0 additions & 3 deletions clevercloud/clever.json

This file was deleted.

6 changes: 4 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ services:
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD:-redis}
- REDIS_PORT=${REDIS_PORT:-6379}
volumes:
volumes:
- bloom-redis:/data
networks:
- bloom_net
Expand All @@ -69,6 +69,8 @@ services:
- bloom-data:/var/lib/postgresql/data
networks:
- bloom_net
volumes:
- bloom-data:/var/lib/postgresql/data
healthcheck:
# PostGis database initialization is done with two steps (postgres+postgis)
# This causes healthcheck to be valid before real full initialization
Expand Down Expand Up @@ -110,7 +112,7 @@ services:
dockerfile: ./docker/frontend/dev.Dockerfile
args:
APP_DIR: /app

volumes:
#- ./frontend:/app
#- ./frontend/node_modules:/app/node_modules
Expand Down
Loading