Skip to content

Commit 5f03e54

Browse files
Merge pull request #130 from uc-cdis/fix/pip-reinstall-gdcddictionary
Fix/pip reinstall gdcddictionary
2 parents 4290b03 + 2095c69 commit 5f03e54

File tree

1 file changed

+38
-25
lines changed

1 file changed

+38
-25
lines changed

.github/workflows/dictionary_push.yaml

+38-25
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@ name: Test and deploy dictionaries
22

33
# OVERVIEW
44
#
5-
# The `dictionaryutils` package is used for dumping the schemas from the parent dictionary repo.
5+
# The `dictionaryutils` package is used for dumping the schemas from the
6+
# parent dictionary repo.
67
# Dependencies on both `gen3dictionary` and `gdcdictionary`
78
# cause conflict in importing the correct `SCHEMA_DIR` used for dumping schemas.
89
#
9-
# There are two steps to ensure setting the correct source:
10-
# - Re-install the dictionary in the parent repo as `gdcdictionary` after the install of `dictionaryutils`
11-
# - uninstall `gen3dictionary` as part of the `run_test.sh` script.
10+
# The purpose of this workflow is to set up a virtual environment where dumped
11+
# schemas are from the parent dictionary repo and are not from those
12+
# installed by dictionaryutils.
1213
#
13-
# In order to ensure the correct virtual env usage and
14-
# compatibility with both pyproject.yaml and setup.py for the dictionary repos, we
15-
# conditionally select `poetry` or `pip` when installing the dictionary as `gdcdictionary`,
14+
# There are two steps to ensure setting the correct source:
15+
# - uninstall `gen3dictionary` and `gdcdictionary` after the dictionaryutils install.
16+
# - Re-install the dictionary in the parent repo as `gdcdictionary`
1617
#
1718
# Then the `run_tests.sh` script will:
18-
# - uninstall `gen3dictionary`
19-
# - run the dictionary tests from dictionaryutils which expects `gdcdictionary` library as the unit to test
20-
# - run the dump schemas to move it to the /artifacts folder
19+
# - run the dictionary tests from dictionaryutils which expects `gdcdictionary`
20+
# library as the unit to test
21+
# - run the dump schemas to move it to the /artifacts folder
22+
#
23+
# All commands should be run under `poetry run` to ensure that changes take
24+
# place in the poetry virtual env.
2125

2226
on:
2327
workflow_call:
@@ -65,31 +69,40 @@ jobs:
6569
git clone https://github.com/uc-cdis/dictionaryutils
6670
cd dictionaryutils
6771
poetry install -vv --all-extras --no-interaction
68-
echo "Removing 'gdcdictionary' and re-installing in following step"
69-
poetry remove gdcdictionary
70-
- name: Attempt poetry or pip re-install of dictionary as `gdcdictionary`
71-
# install via pip or poetry conditionally
72+
- name: Uninstall gdcdictionary
73+
# remove gdcdictionary or gen3dictionary conditionally
7274
run: |
73-
echo "installing the dictionary as 'gdcdictionary'"
74-
if [ -f setup.py ]; then
75-
echo "Install via pip"
76-
pip install .
77-
fi
7875
if [ -f pyproject.toml ]; then
79-
echo "Install via poetry"
80-
poetry install -vv --all-extras --no-interaction || true
76+
cd dictionaryutils
77+
echo "Removing 'gen3dictionary' via pip"
78+
poetry run pip uninstall -y gen3dictionary
79+
poetry run pip uninstall -y gdcdictionary
80+
elif [ -f setup.py ]; then
81+
cd dictionaryutils
82+
echo "Removing 'gdcdictionary' via poetry"
83+
poetry remove gdcdictionary
84+
poetry run pip uninstall -y gen3dictionary
8185
fi
86+
- name: Attempt re-install of dictionary as `gdcdictionary`
87+
run: |
88+
echo "Re-installing the dictionary as 'gdcdictionary'"
89+
cd dictionaryutils
90+
poetry run pip install ..
8291
- name: Run dictionary tests, dump schema, and move to S3
8392
run: |
8493
cd dictionaryutils
8594
echo "dependencies before run_test"
8695
poetry show
96+
echo "Schema dir for artifact"
97+
poetry run python -c "from gdcdictionary import SCHEMA_DIR; print(SCHEMA_DIR)"
98+
echo "Schemas"
99+
ls `poetry run python -c "from gdcdictionary import SCHEMA_DIR; print(SCHEMA_DIR)"`
100+
echo "Run tests under poetry"
87101
poetry run ./run_tests.sh
88-
echo "dependencies after run_test"
89-
poetry show
102+
echo "Number of schemas in artifact"
103+
grep -o ".yaml\"" artifacts/schema.json | wc -l
90104
aws s3 cp artifacts/schema.json s3://${{ inputs.BUCKET }}/${{ inputs.DIRECTORY }}/$GITHUB_REF_NAME/schema.json --region ${{ inputs.REGION }}
91-
echo "Schema dir for artifact: "
92-
python -c "from gdcdictionary import SCHEMA_DIR; print(SCHEMA_DIR)"
105+
93106
env:
94107
AWS_ACCESS_KEY_ID: ${{ secrets.DICT_AWS_ACCESS_KEY_ID }}
95108
AWS_SECRET_ACCESS_KEY: ${{ secrets.DICT_AWS_SECRET_ACCESS_KEY }}

0 commit comments

Comments
 (0)