Skip to content

Commit

Permalink
Merge pull request #22 from lsst/tickets/DM-31272
Browse files Browse the repository at this point in the history
[DM-31272] Set schema index based on felis files
  • Loading branch information
cbanek committed Sep 29, 2021
2 parents 622fabc + 2f887c2 commit 73df891
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
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
./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()

0 comments on commit 73df891

Please sign in to comment.