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

Refactor to Use Mission Specific Requirement Files #23

Merged
Merged
9 changes: 7 additions & 2 deletions .github/workflows/calibration.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Test Lambda Function Locally and Upload Artifacts

on: [pull_request, pull_request_target]
on: [pull_request]

jobs:
test-and-upload:
Expand All @@ -19,7 +19,7 @@ jobs:

- name: Run Lambda Docker Container
run: |
docker run -d -p 9000:8080 -e USE_INSTRUMENT_TEST_DATA=True processing_function:latest
docker run -d --name processing_lambda -p 9000:8080 -e USE_INSTRUMENT_TEST_DATA=True -e SWXSOC_MISSION=hermes processing_function:latest
container_id=$(docker ps -qf "ancestor=processing_function:latest")
echo "Container ID: $container_id"

Expand All @@ -37,6 +37,9 @@ jobs:
STATUS_CODE=$(echo $HTTP_STATUS | grep -oP '200')
echo "Status Code: $STATUS_CODE"

# Show logs from the container
docker logs processing_lambda

# If the HTTP status code is 200, then the test is successful
if [ "$STATUS_CODE" == "200" ]; then
echo "Success: HTTP status is 200"
Expand All @@ -47,6 +50,8 @@ jobs:
echo "test_success=false" >> $GITHUB_OUTPUT
exit 1 # Exit with failure
fi



- name: Copy Processed Files from Container
if: steps.test-lambda.outputs.test_success == 'true'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ jobs:
- name: Run tests
run: |
pytest --pyargs lambda_function --cov lambda_function/src
env:
SWXSOC_MISSION: hermes

6 changes: 5 additions & 1 deletion lambda_function/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ FROM ${BASE_IMAGE}
ARG ROOT="/"
ARG FUNCTION_DIR="/lambda_function/"

COPY requirements.txt ${ROOT}
# Set default values for requirements file
ARG REQUIREMENTS_FILE="hermes-requirements.txt"

# Copy requirements file to root directory
COPY ${REQUIREMENTS_FILE} ${ROOT}requirements.txt

# Update pip and install setuptools
RUN pip install --upgrade pip setuptools
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
spacepy==0.5.0
sdc_aws_utils @ git+https://github.com/HERMES-SOC/sdc_aws_utils.git
hermes_spani @ git+https://github.com/HERMES-SOC/hermes_spani.git
hermes_eea @ git+https://github.com/HERMES-SOC/hermes_eea.git
hermes_nemisis @ git+https://github.com/HERMES-SOC/hermes_nemisis.git
hermes_merit @ git+https://github.com/HERMES-SOC/hermes_merit.git
psycopg2-binary==2.9.7
3 changes: 3 additions & 0 deletions lambda_function/padre-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sdc_aws_utils @ git+https://github.com/HERMES-SOC/sdc_aws_utils.git
padre_meddea @ git+https://github.com/PADRESat/padre_meddea.git
padre_sharp @ git+https://github.com/PADRESat/padre_sharp.git
6 changes: 4 additions & 2 deletions lambda_function/tests/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import json
from moto import mock_s3
from pathlib import Path
from swxsoc import log

log.disable_warnings_logging() # noqa: E402

os.environ["SDC_AWS_CONFIG_FILE_PATH"] = "lambda_function/src/config.yaml"
from src.file_processor.file_processor import ( # noqa: E402
Expand Down Expand Up @@ -39,7 +41,7 @@ def test_file_calibrate():
calibrated_file_path = FileProcessor._calibrate_file(intrument, file_path)

# Verify
assert calibrated_file_path == "hermes_eea_l1_20230211T000000_v1.0.0.cdf"
assert calibrated_file_path == "hermes_eea_l1_20000101T170901_v1.0.0.cdf"

# Cleanup
os.remove(Path(parent_dir, calibrated_file_path))
Expand All @@ -63,7 +65,7 @@ def test_file_calibrate_failure():
def test_handle_event(s3):
filename = "hermes_EEA_l0_2023042-000000_v0.bin"
parent_dir = "lambda_function/tests/test_data"
calibrated_file_path = "hermes_eea_l1_20230211T000000_v1.0.0.cdf"
calibrated_file_path = "hermes_eea_l1_20000101T170901_v1.0.0.cdf"
# Set the absolute path using file_path as string
os.environ["SDC_AWS_FILE_PATH"] = f"lambda_function/tests/test_data/{filename}"

Expand Down
Loading