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

[DM-31272] Set schema index based on felis files #22

Merged
merged 2 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 4 additions & 11 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@ jobs:
- name: Check out repo
uses: actions/checkout@v2

- name: Check out felis
uses: actions/checkout@v2
with:
repository: lsst-dm/felis.git
ref: u/bvan/tap11_fix
path: felis

- name: Install felis
id: felis
run: pip install .
working-directory: ./felis
- name: Install dependencies
id: depend
run: pip install -r requirements.txt
working-directory: ./tap-schema

- name: Log in to Docker Hub
uses: docker/login-action@v1
Expand Down
4 changes: 3 additions & 1 deletion tap-schema/build
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ ENVIRONMENT="$1"
GIT_TAG=`echo $GITHUB_REF | sed -E 's,refs/(heads|tags)/,,' | sed -E 's,/,-,g'`
shift

./set_schema_index $@

# Generate SQL files from Felis yaml files
# Place the SQL files in the sql directory, which gets
# copied into the docker image.
for file in $@
do
felis load-tap --dry-run --engine-url=postgresql+psycopg2:// --tap-schema-name=tap_schema --tap-tables-postfix=11 ../yml/$file > sql/$file.sql
felis load-tap --dry-run --engine-url=postgresql+psycopg2:// --tap-schema-name=tap_schema --tap-tables-postfix=11 $file > sql/`basename $file`.sql
done

# Build and push docker images
Expand Down
8 changes: 4 additions & 4 deletions tap-schema/build-all
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -ex
./build mock
./build stable hsc_gen2.yaml hsc.yaml wise_01.yml dp01_dc2.yaml
./build int hsc_gen2.yaml hsc.yaml wise_01.yml dp01_dc2.yaml
./build idfprod dp01_dc2.yaml
./build idfint dp01_dc2.yaml
./build stable ../yml/hsc_gen2.yaml ../yml/hsc.yaml ../yml/wise_01.yml ../yml/dp01_dc2.yaml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems potentially more error-prone when edited by, shall we say, clueless scientists. :)

./build int ../yml/hsc_gen2.yaml ../yml/hsc.yaml ../yml/wise_01.yml ../yml/dp01_dc2.yaml
./build idfprod ../yml/dp01_dc2.yaml
./build idfint ../yml/dp01_dc2.yaml
3 changes: 3 additions & 0 deletions tap-schema/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
click
pyyaml
git+git://github.com/lsst-dm/felis.git@master#egg=felis
21 changes: 21 additions & 0 deletions tap-schema/set_schema_index
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python

import click
import yaml

@click.command()
@click.argument('felis_files', nargs=-1)
def set_schema_index(felis_files):
for idx, f in enumerate(felis_files):
click.echo(f"file {f}: index {idx}")

with open(f) as orig_file:
felis_yaml = yaml.load(orig_file.read())

felis_yaml["tap:schema_index"] = idx

with open(f, "w") as output_file:
output_file.write(yaml.dump(felis_yaml))

if __name__ == '__main__':
set_schema_index()