Skip to content

Commit

Permalink
Astro Migration (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
keegansmith21 authored Mar 17, 2024
1 parent 3ddef54 commit ad505cf
Show file tree
Hide file tree
Showing 360 changed files with 6,392 additions and 6,689 deletions.
2 changes: 2 additions & 0 deletions .astro/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project:
name: oaebu-workflows
19 changes: 19 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Astronomer CI - Deploy code

on:
push:
tags:
- 'v*'

env:
## Set API Token as an environment variable
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to Astro
uses: astronomer/deploy-action@v0.4
with:
deployment-id: ${{ secrets.ASTRO_DEPLOYMENT_ID }}
17 changes: 10 additions & 7 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Unit Tests

on: [push, merge_group]
on: [push]

jobs:
build:
Expand All @@ -13,12 +13,12 @@ jobs:

steps:
- name: Checkout ${{ matrix.python-version }}
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
lfs: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -27,14 +27,17 @@ jobs:
python -m pip install --upgrade pip
cd ..
git clone https://github.com/The-Academic-Observatory/observatory-platform.git
git clone -b feature/astro-refactor https://github.com/The-Academic-Observatory/observatory-platform.git
cd observatory-platform
pip install -e observatory-api --constraint https://raw.githubusercontent.com/apache/airflow/constraints-2.6.3/constraints-no-providers-${{ matrix.python-version }}.txt
pip install -e observatory-platform --constraint https://raw.githubusercontent.com/apache/airflow/constraints-2.6.3/constraints-no-providers-${{ matrix.python-version }}.txt
pip install -e .[tests] --constraint https://raw.githubusercontent.com/apache/airflow/constraints-2.7.3/constraints-no-providers-${{ matrix.python-version }}.txt
cd ..
cd oaebu-workflows
pip install -e .[tests] --constraint https://raw.githubusercontent.com/apache/airflow/constraints-2.6.3/constraints-no-providers-${{ matrix.python-version }}.txt
pip install -r requirements.txt --constraint https://raw.githubusercontent.com/apache/airflow/constraints-2.7.3/constraints-no-providers-${{ matrix.python-version }}.txt
- name: Add dag folder to PYTHONPATH
run: |
echo "PYTHONPATH=$HOME/work/oaebu-workflows/oaebu-workflows/dags" >> "$GITHUB_ENV"
# Required for testing ONIX Telescope
- name: Set up JDK 11
Expand Down
14 changes: 4 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
.idea
venv
*.egg-info
dist
.vscode
docs/_build
config.yaml
*.pkrvars.hcl
*.tfvars
*.tfstate
*.tfstate.*
.terraform.tfstate.lock.info
.terraform/**
.coverage
coverage.xml
config_terraform.yaml
*.pyc
AUTHORS
ChangeLog
.eggs/
.DS_Store
/oaebu_workflows/workflows/oapen_cloud_function.zip
docs/schemas
*.Rhistory
.env
__pycache__
/oaebu-workflows/build

# Astronomer
airflow_settings.yaml
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM quay.io/astronomer/astro-runtime:9.10.0

# Root user for installations
USER root

# Install git
RUN apt-get update && apt-get install git -y

USER astro

# Install Observatory Platform
RUN git clone --branch feature/astro-refactor https://github.com/The-Academic-Observatory/observatory-platform.git
RUN pip install -e ./observatory-platform/ --constraint https://raw.githubusercontent.com/apache/airflow/constraints-2.7.3/constraints-no-providers-3.10.txt
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions dags/load_dags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from observatory_platform.airflow.workflow import load_dags_from_config

load_dags_from_config()
File renamed without changes.
File renamed without changes.
22 changes: 14 additions & 8 deletions oaebu_workflows/config.py → dags/oaebu_workflows/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 Curtin University
# Copyright 2020-2024 Curtin University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@
import os
from typing import Optional

from observatory.platform.config import module_file_path
from observatory_platform.config import module_file_path


def test_fixtures_folder(workflow_module: Optional[str] = None) -> str:
Expand All @@ -29,9 +29,9 @@ def test_fixtures_folder(workflow_module: Optional[str] = None) -> str:
"""

if workflow_module is not None:
return construct_module_path("oaebu_workflows", workflow_module, "tests", "fixtures")
return construct_module_path("tests", workflow_module, "fixtures")

return construct_module_path("oaebu_workflows", "tests", "fixtures")
return construct_module_path("tests", "fixtures")


def schema_folder(workflow_module: Optional[str] = None) -> str:
Expand All @@ -43,9 +43,9 @@ def schema_folder(workflow_module: Optional[str] = None) -> str:
"""

if workflow_module is not None:
return construct_module_path("oaebu_workflows", workflow_module, "schema")
return construct_module_path("dags", "oaebu_workflows", workflow_module, "schema")

return construct_module_path("oaebu_workflows", "schema")
return construct_module_path("dags", "oaebu_workflows", "schema")


def sql_folder(workflow_module: Optional[str] = None) -> str:
Expand All @@ -57,9 +57,9 @@ def sql_folder(workflow_module: Optional[str] = None) -> str:
"""

if workflow_module is not None:
return construct_module_path("oaebu_workflows", workflow_module, "sql")
return construct_module_path("dags", "oaebu_workflows", workflow_module, "sql")

return construct_module_path("oaebu_workflows", "sql")
return construct_module_path("dags", "oaebu_workflows", "sql")


def construct_module_path(*parts: str) -> str:
Expand All @@ -71,3 +71,9 @@ def construct_module_path(*parts: str) -> str:
raise FileNotFoundError(f"construct_module_path: directory {file_path} does not exist!")

return file_path


def oaebu_user_agent_header() -> dict:
return {
"User-Agent": "oaebu-workflows v1.0.0 (+https://github.com/The-Academic-Observatory/oaebu-workflows; mailto:agent@observatory.academy) "
}
Loading

0 comments on commit ad505cf

Please sign in to comment.