Skip to content

Commit

Permalink
More flexible build process for Athena (#325)
Browse files Browse the repository at this point in the history
Co-authored-by: Maximilian Sölch <[email protected]>
  • Loading branch information
dmytropolityka and maximiliansoelch authored Sep 4, 2024
1 parent ccf0330 commit 5d3b517
Show file tree
Hide file tree
Showing 210 changed files with 15,966 additions and 14,830 deletions.
10 changes: 7 additions & 3 deletions .github/scripts/images-to-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ fi
# Check if athena folder was changed (then we need to build all module_* images)
ATHENA_CHANGED=$(echo "$CHANGED_FILES" | grep -q "^athena" && echo "true" || echo "false")

# Loop over all root level directories
for DIR in */; do
# Loop over all root level directories and modules
for DIR in modules/*/*/ */; do
# If a Dockerfile exists in the directory
if [[ -e "${DIR}Dockerfile" ]]; then
DIR=${DIR%/} # Remove trailing slash
Expand All @@ -44,6 +44,7 @@ for DIR in */; do
continue
fi


# Build all images on develop branch
if [[ "$GITHUB_REF" == "refs/heads/develop" ]]; then
DIRS+=("$DIR")
Expand All @@ -56,8 +57,11 @@ for DIR in */; do
continue
fi

# Extract just the final directory name (e.g., "module_example") from the full path
IMAGE_NAME_SUFFIX=$(basename "$DIR")

# Construct Docker image name and tag
IMAGE_NAME="athena/$DIR"
IMAGE_NAME="athena/$IMAGE_NAME_SUFFIX"
IMAGE_TAG="pr-$PR_NUMBER"

# Check if any file has changed in that directory since the pull request was created
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}


- name: Set IMAGE_NAME
run: echo "IMAGE_NAME=$(basename ${{ matrix.image }})" >> $GITHUB_ENV

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository_owner }}/Athena/${{ matrix.image }}
ls1tum/athena_${{ matrix.image }}
ghcr.io/${{ github.repository_owner }}/Athena/${{ env.IMAGE_NAME }}
ls1tum/athena_${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ github.ref == 'refs/heads/develop' && 'develop' || github.sha }}
type=raw,value=${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.sha }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ jobs:
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
poetry install
poetry run install_all
- name: Run Prospector
run: poetry run prospector
run: poetry run lint_all
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Tests

on:
push:
branches:
- develop
pull_request:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Cache Poetry dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install dependencies
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
poetry install
poetry run install_all
- name: Run tests
run: poetry run test_all
24 changes: 0 additions & 24 deletions .idea/runConfigurations/module_programming_llm.xml

This file was deleted.

8 changes: 4 additions & 4 deletions .prospector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ autodetect: false

ignore-paths:
- docs
- module_text_cofee/module_text_cofee/protobuf
- module_programming_themisml/module_programming_themisml/extract_methods/languages
- module_programming_themisml/module_programming_themisml/extract_methods/method_parser_listener.py
- module_programming_apted/module_programming_apted/convert_code_to_ast/languages
- module_text_cofee/protobuf
- module_programming_themisml/extract_methods/languages
- module_programming_themisml/extract_methods/method_parser_listener.py
- module_programming_apted/convert_code_to_ast/languages

mypy:
run: true
Expand Down
19 changes: 13 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,52 @@
"name": "Module Example",
"type": "python",
"request": "launch",
"cwd": "${workspaceFolder}/module_example",
"cwd": "${workspaceFolder}/modules/programming/module_example",
"module": "module_example",
"justMyCode": true
},
{
"name": "Module Programming LLM",
"type": "python",
"request": "launch",
"cwd": "${workspaceFolder}/module_programming_llm",
"cwd": "${workspaceFolder}/modules/programming/module_programming_llm",
"module": "module_programming_llm",
"justMyCode": true
},
{
"name": "Module Programming ThemisML",
"type": "python",
"request": "launch",
"cwd": "${workspaceFolder}/module_programming_themisml",
"cwd": "${workspaceFolder}/modules/programming/module_programming_themisml",
"module": "module_programming_themisml"
},
{
"name": "Module Programming APTED",
"type": "python",
"request": "launch",
"cwd": "${workspaceFolder}/module_programming_apted",
"cwd": "${workspaceFolder}/modules/programming/module_programming_apted",
"module": "module_programming_apted"
},
{
"name": "Module Text LLM",
"type": "python",
"request": "launch",
"cwd": "${workspaceFolder}/module_text_llm",
"cwd": "${workspaceFolder}/modules/text/module_text_llm",
"module": "module_text_llm",
"justMyCode": true
},
{
"name": "Module Text CoFee",
"type": "python",
"request": "launch",
"cwd": "${workspaceFolder}/module_text_cofee",
"cwd": "${workspaceFolder}/modules/text/module_text_cofee",
"module": "module_text_cofee"
},
{
"name": "Module Modeling LLM",
"type": "python",
"request": "launch",
"cwd": "${workspaceFolder}/modules/modeling/module_modeling_llm",
"module": "module_text_cofee"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ class Module(BaseModel):
url: AnyHttpUrl = Field(example="http://localhost:5001")
type: ExerciseType = Field(example=ExerciseType.text)
supports_evaluation: bool = Field(description="Whether the module supports evaluation", example=True)
supports_non_graded_feedback_requests: bool = Field(description="Whether the module supports non-graded feedback requests", example=True),
supports_non_graded_feedback_requests: bool = Field(description="Whether the module supports non-graded feedback requests", example=True)
supports_graded_feedback_requests: bool = Field(description="Whether the module supports graded feedback requests", example=True)
Loading

0 comments on commit 5d3b517

Please sign in to comment.