Skip to content
Open
Changes from 5 commits
Commits
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
24 changes: 23 additions & 1 deletion src/satellite_consumer/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
"""

import datetime as dt
import os
from importlib.metadata import PackageNotFoundError, version

from dotenv import load_dotenv
import sentry_sdk
import eumdac.product
from joblib import Parallel, delayed
from loguru import logger as log
Expand All @@ -23,11 +26,29 @@
from satellite_consumer.storage import create_empty_zarr, create_latest_zip, get_fs, write_to_zarr
from satellite_consumer.validate import validate

# Load environment variables from .env file
load_dotenv()

# Get Sentry DSN from environment variables
SENTRY_DSN = os.getenv("SENTRY_DSN")

# Initialize Sentry if DSN is available
if SENTRY_DSN:
sentry_sdk.init(
dsn=SENTRY_DSN, # Using .env variable
traces_sample_rate=1.0,
environment=os.getenv("ENVIRONMENT", "production") # Get from ENVIRONMENT variable
)
log.info("✅ Sentry initialized successfully!")
else:
log.warning("⚠️ SENTRY_DSN is not set. Sentry will not be initialized.")

try:
__version__ = version("satellite-consumer")
except PackageNotFoundError:
__version__ = "v?"


def _consume_command(command_opts: ArchiveCommandOptions | ConsumeCommandOptions) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you reset all changes below this, if you want to do this, please put in a different PR and explain what they are for and why

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is green lines below here, then it means new lines have been added

"""Run the download and processing pipeline."""
fs = get_fs(path=command_opts.zarr_path)
Expand Down Expand Up @@ -79,7 +100,8 @@ def _etl(product: eumdac.product.Product) -> str:
f"Deleting {len(nat_filepaths)} raw files in {command_opts.raw_folder}",
num_files=len(nat_filepaths), dst=command_opts.raw_folder,
)
_ = [f.unlink() for f in nat_filepaths] # type:ignore
for f in nat_filepaths:
f.unlink() # type: ignore # Removed unnecessary list comprehension


def run(config: SatelliteConsumerConfig) -> None:
Expand Down