-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Darshan
committed
Feb 17, 2025
1 parent
c64c50e
commit f200bb9
Showing
36 changed files
with
853 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2025 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ============================================================================== | ||
|
||
FROM continuumio/miniconda3:latest | ||
|
||
# Add the mamba solver for faster builds | ||
RUN conda install -n base conda-libmamba-solver | ||
RUN conda config --set solver libmamba | ||
|
||
# Clone the weather-tools and create conda env using environment.yml of weather-tools. | ||
ARG weather_tools_git_rev=main | ||
RUN git clone https://github.com/google/weather-tools.git /weather | ||
WORKDIR /weather | ||
RUN git checkout "${weather_tools_git_rev}" | ||
RUN rm -r /weather/weather_*/test_data/ | ||
RUN conda env create -f environment.yml --debug | ||
|
||
# Activate the conda env and update the PATH | ||
ARG CONDA_ENV_NAME=weather-tools | ||
RUN echo "source activate ${CONDA_ENV_NAME}" >> ~/.bashrc | ||
ENV PATH /opt/conda/envs/${CONDA_ENV_NAME}/bin:$PATH | ||
RUN pip install -e . | ||
|
||
ARG arco_era5_git_rev=era5t-support | ||
RUN git clone https://github.com/google-research/arco-era5.git /arco-era5 | ||
WORKDIR /arco-era5 | ||
RUN git checkout "${arco_era5_git_rev}" | ||
RUN pip install -e . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Copyright 2025 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from google.cloud import run_v2 | ||
import constants | ||
|
||
|
||
def create_job(job_id: str, template: run_v2.ExecutionTemplate): | ||
# Create a client | ||
client = run_v2.JobsClient() | ||
|
||
# Initialize request argument(s) | ||
job = run_v2.Job() | ||
job.template = template | ||
|
||
request = run_v2.CreateJobRequest( | ||
parent=f"projects/{constants.PROJECT}/locations/{constants.REGION}", | ||
job=job, | ||
job_id=job_id, | ||
) | ||
|
||
# Make the request | ||
operation = client.create_job(request=request) | ||
|
||
print("Waiting for operation to complete...") | ||
|
||
response = operation.result() | ||
|
||
# Handle the response | ||
print(response) | ||
|
||
|
||
def graphnn_job_creator( | ||
job_id: str, | ||
timeout_sec: int, | ||
container_args: list = None, | ||
contaner_env: list = None, | ||
container_memory_limit: str = None, | ||
max_retries: int = 0 | ||
): | ||
# Create an ExecutionTemplate | ||
template = run_v2.ExecutionTemplate() | ||
template.task_count = constants.TASK_COUNT | ||
|
||
template.template.timeout = {"seconds": timeout_sec} | ||
template.template.max_retries = max_retries | ||
|
||
# Set container details | ||
container = run_v2.Container() | ||
container.name = constants.CONTAINER_NAME | ||
container.image = constants.CLOUD_RUN_CONTAINER_IMAGE | ||
container.command = constants.CONTAINER_COMMAND | ||
container.args = container_args | ||
|
||
# Set environment variables (example) | ||
container.env = contaner_env | ||
|
||
# Set resource limits (example) | ||
container.resources.limits = { | ||
"cpu": constants.CONTAINER_CPU_LIMIT, | ||
"memory": container_memory_limit, | ||
} | ||
|
||
# Add the container to the template | ||
template.template.containers.append(container) | ||
|
||
create_job(job_id, template) | ||
|
||
|
||
if __name__ == "__main__": | ||
graphnn_job_creator( | ||
job_id=constants.SANITY_JOB_ID, | ||
timeout_sec=constants.TIMEOUT_SECONDS, | ||
container_memory_limit=constants.CONTAINER_MEMORY_LIMIT, | ||
) | ||
graphnn_job_creator( | ||
job_id=constants.INGESTION_JOB_ID, | ||
timeout_sec=constants.TIMEOUT_SECONDS, | ||
container_memory_limit=constants.CONTAINER_MEMORY_LIMIT, | ||
) | ||
graphnn_job_creator( | ||
job_id=constants.DAILY_EXECUTOR_JOB_ID, | ||
timeout_sec=constants.TIMEOUT_SECONDS, | ||
container_args=constants.DAILY_EXECUTOR_JOB_CONTAINER_ARGS, | ||
contaner_env=constants.JOB_CONTAINER_ENV_VARIABLES + constants.ERA5T_API_KEYS, | ||
container_memory_limit=constants.CONTAINER_MEMORY_LIMIT, | ||
) | ||
graphnn_job_creator( | ||
job_id=constants.MONTHLY_EXECUTOR_JOB_ID, | ||
timeout_sec=constants.TIMEOUT_SECONDS, | ||
container_args=constants.MONTHLY_EXECUTOR_JOB_CONTAINER_ARGS, | ||
contaner_env=constants.JOB_CONTAINER_ENV_VARIABLES + constants.ERA5T_API_KEYS, | ||
container_memory_limit=constants.CONTAINER_MEMORY_LIMIT, | ||
) | ||
graphnn_job_creator( | ||
job_id=constants.EXECUTOR_JOB_ID, | ||
timeout_sec=constants.TIMEOUT_SECONDS, | ||
container_args=constants.EXECUTOR_JOB_CONTAINER_ARGS, | ||
contaner_env=constants.JOB_CONTAINER_ENV_VARIABLES + constants.ERA5_API_KEYS, | ||
container_memory_limit=constants.CONTAINER_MEMORY_LIMIT, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.