Skip to content

Commit

Permalink
Fix generate-docs and lint recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
sarayourfriend committed Sep 20, 2024
1 parent f97a5e6 commit 9904123
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
13 changes: 8 additions & 5 deletions catalog/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ shell:
env DC_USER="airflow" just ../exec {{ SERVICE }} /bin/bash

# Launch an IPython shell in a new container under `SERVICE`
[positional-arguments]
ipython *args: up-deps
env DC_USER="airflow" just ../run \
--workdir /opt/airflow/catalog/dags \
{{ SERVICE }} \
bash -c \'ipython {{ args }}\'
bash -c "ipython ${@:2}"

# Launch a `pgcli` shell in the PostgreSQL container
pgcli db_user_pass="deploy" db_name="openledger": up
Expand Down Expand Up @@ -124,7 +125,7 @@ test *args:

# Generate the documentation (either "dag" or "media-props")
generate-docs doc="dag" fail_on_diff="false":
#!/bin/bash
#! /usr/bin/env bash
set -e
if [ "{{ doc }}" == "dag" ]; then
SCRIPT_PATH="catalog/utilities/dag_doc_gen/dag_doc_generation.py"
Expand All @@ -140,18 +141,20 @@ generate-docs doc="dag" fail_on_diff="false":
echo "Invalid documentation type specified, use \`dag\` or \`media-props\`. Exiting."
exit 1
fi

GENERATED_ABS_PATH="/opt/airflow/catalog/${GENERATED_REL_PATH}"
just ../run \
--volume {{ justfile_directory() }}/../docker:/opt/airflow/docker/ \
-e PYTHONPATH=/opt/airflow/catalog:/opt/airflow/catalog/dags \
{{ SERVICE }} \
"bash -c 'python $SCRIPT_PATH && chmod 666 $GENERATED_ABS_PATH'"
bash -c "python $SCRIPT_PATH && chmod 666 $GENERATED_ABS_PATH"

TEMP="documentation/meta/temp"
mv ../catalog/$GENERATED_REL_PATH ../$TEMP.md
mv ../catalog/"$GENERATED_REL_PATH" ../"$TEMP".md
echo "Moved the generated file to ../$TEMP.md"
echo -n "Running linting..."
# Linting step afterwards is necessary since the generated output differs greatly from what prettier expects
just ../lint prettier $TEMP.md &>/dev/null || true
just ../lint prettier "$TEMP".md &>/dev/null || true
echo "Linting done!"

echo -n "Replacing linted md <hr> '---' with '----' required by sphinx..."
Expand Down
8 changes: 1 addition & 7 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,8 @@ precommit:
fi

# Run pre-commit to lint and reformat files
[positional-arguments]
lint hook="" *files="": precommit
#! /usr/bin/env bash
if [[ "$files" ]]; then
python3 pre-commit.pyz run {{ hook }} --files "${@:2}"
else
python3 pre-commit.pyz run {{ hook }} --all-files
fi
python3 pre-commit.pyz run {{ hook }} {{ if files == "" { "--all-files" } else { "--files" } }} {{ files }}

# Run codeowners validator locally. Only enable experimental hooks if there are no uncommitted changes.
lint-codeowners checks="stable":
Expand Down

0 comments on commit 9904123

Please sign in to comment.