Skip to content

Commit

Permalink
Jsonify list for older versions of flask
Browse files Browse the repository at this point in the history
  • Loading branch information
fritz-astronomer committed May 21, 2024
1 parent 849b516 commit cb97bbc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion astronomer_starship/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.0.2"
__version__ = "2.0.3"


def get_provider_info():
Expand Down
6 changes: 5 additions & 1 deletion astronomer_starship/starship_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import json
from functools import partial

import flask
from airflow.plugins_manager import AirflowPlugin
from airflow.www.app import csrf
from flask import Blueprint, request, jsonify
Expand Down Expand Up @@ -91,8 +93,10 @@ def starship_route(
}
)
res.status_code = 500

# https://github.com/pallets/flask/issues/4659
# noinspection PyUnboundLocalVariable
return res
return jsonify(res) if flask.__version__ < "2.2" and isinstance(res, list) else res


class StarshipApi(BaseView):
Expand Down
25 changes: 21 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DOCS_DIR := "docs"
VERSION := `echo $(python -c 'from astronomer_starship import __version__; print(__version__)')`

default:
@just --choose
@just --choose

# Print this help text
help:
Expand All @@ -15,6 +15,7 @@ help:
install-precommit:
pre-commit install


# install frontend requirements
install-frontend:
cd astronomer_starship && npm install
Expand All @@ -26,49 +27,60 @@ install-backend EDITABLE="":
# Install the project
install: clean install-frontend install-backend

# Run container test via docker
test-run-container-test IMAGE="apache/airflow:2.3.4":
docker run --entrypoint=bash -e DOCKER_TEST=True \
-v "$HOME/starship:/usr/local/airflow/starship:rw" \
{{IMAGE}} -- \
/usr/local/airflow/starship/tests/docker_test/run_container_test.sh \
{{IMAGE}}


# Test Starship Python API
test-backend:
pytest -c pyproject.toml

# Test Starship Python API with coverage
test-backend-with-coverage:
pytest -c pyproject.toml --cov=./ --cov-report=xml

# Test Starship Webapp Frontend
test-frontend:
cd astronomer_starship && npx vitest run

# Test the frontend and retest while watching for changes
test-frontend-watch:
cd astronomer_starship && npx vitest watch

# Run unit tests
test: test-frontend test-backend

# Run unit tests with coverage
test-with-coverage: test-frontend test-backend-with-coverage

# Run integration tests
test-integration $MANUAL_TESTS="true":
@just test

# Test CICD setup with `act`
test-cicd:
act pull-request -W .github/workflows/checks.yml --container-architecture linux/amd64
act pull-request -W .github/workflows/checks.yml --container-architecture linux/amd64

# Lint the frontend code
lint-frontend:
cd astronomer_starship && npx eslint .. --ext js,jsx --report-unused-disable-directives --max-warnings 0

# Lint the backend code
lint-backend:
ruff -c pyproject.toml

# Run all linting
lint: lint-frontend lint-backend


# Build Starship Webapp Frontend
build-frontend: clean-frontend-build
cd astronomer_starship && npx vite build

# Build the frontend and rebuild while watching for changes
build-frontend-watch:
cd astronomer_starship && npx vite build --watch

Expand All @@ -84,12 +96,15 @@ clean-backend-build:
rm -rf dist dist
rm -rf *.egg-info

# Clean artifacts created after building the frontend
clean-frontend-build:
rm -rf astronomer_starship/static

# Clean artifacts used by the frontend
clean-frontend-install:
rm -rf astronomer_starship/node_modules

# Clean everything
clean: clean-backend-build clean-frontend-build clean-frontend-install

# Tag as v$(<src>.__version__) and push to GH
Expand All @@ -99,9 +114,11 @@ tag:
# Tag and push
git tag v{{VERSION}}

# Deploy the project
deploy-tag: tag
git push origin v{{VERSION}}

# Deploy the project
deploy: deploy-tag

# Upload to TestPyPi for testing (note: you can only use each version once)
Expand Down

0 comments on commit cb97bbc

Please sign in to comment.