Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker #10

Merged
merged 11 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 9 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Use an official Python runtime as a parent image
FROM python:3.11-slim as base

Check warning on line 2 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-container

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

RUN apt-get update && \
apt-get install -y --no-install-recommends git && \
RUN apt-get update
RUN apt-get install unzip -y
RUN apt-get install -y --no-install-recommends git && \
rm -rf /var/lib/apt/lists/*

# Copy the application files
COPY src /app/src
COPY pyproject.toml app/pyproject.toml
COPY README.md app/README.md

# Set the working directory in the container
WORKDIR /app

# Copy the requirements file and install
COPY pyproject.toml ./
RUN pip install --no-cache-dir .

# Copy the application files
COPY src /app/src
RUN pip install -e .

# Set the entrypoint command to run the app
CMD ["python", "src/cloudcasting_app/app.py"]
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ classifiers = [
]
dependencies = [
"torch[cpu]",
"fsspec[s3]",
"fsspec",
"s3fs",
"xarray",
"zarr<3.0",
"numpy",
Expand Down
8 changes: 6 additions & 2 deletions src/cloudcasting_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
# ---------------------------------------------------------------------------
# GLOBAL SETTINGS

logging.basicConfig(
level=getattr(logging, os.getenv("LOGLEVEL", "INFO")),
format="[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s",
)

# Create a logger
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -132,13 +136,13 @@ def app(t0=None):
ds_y_hat = da_y_hat.to_dataset(name="sat_pred")
ds_y_hat.sat_pred.attrs.update(ds.data.attrs)

# Save predictions to latest path and to path with timestring
# Save predictions to the latest path and to path with timestring
out_dir = os.environ["OUTPUT_PREDICTION_DIRECTORY"]

latest_zarr_path = f"{out_dir}/latest.zarr"
t0_string_zarr_path = t0.strftime(f"{out_dir}/%Y-%m-%dT%H:%M.zarr")

fs, _ = fsspec.core.url_to_fs(out_dir)
fs = fsspec.open(out_dir).fs
Copy link
Member

@dfulu dfulu Feb 4, 2025

Choose a reason for hiding this comment

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

Did this change solve something? I thought the old one was cleaner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, for some reason that didn't work. Perhaps something to check in the future. It might have done, i just mvoed it back to something i know it definately works

for path in [latest_zarr_path, t0_string_zarr_path]:

# Remove the path if it exists already
Expand Down