-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add GC content std.dev. limit and coverage std. dev. limit Binning metrics #120
Changes from 10 commits
347b4b4
574e8a6
23a72b3
369acab
989160f
1473d31
2f527aa
dc7808d
964cc8c
572034f
c2ce747
f152b0a
169987b
81cc406
b6a5014
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,148 @@ | ||
hello: | ||
@echo "Please inspect Makefile for list of commands" | ||
.PHONY: clean black create_environment install image docs clean unit_test unit_test_data unit_test_data_download unit_test_data_build unit_test_wip unit_test_entrypoints | ||
|
||
################################################################################# | ||
# GLOBALS # | ||
################################################################################# | ||
|
||
PROJECT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
PROJECT_NAME = autometa | ||
PYTHON_INTERPRETER = python3 | ||
# This was retrieved from https://drive.google.com/file/d/1bSlPldaq3C6Cf9Y5Rm7iwtUDcjxAaeEk/view?usp=sharing | ||
TEST_DATA_FILEID = 1bSlPldaq3C6Cf9Y5Rm7iwtUDcjxAaeEk | ||
|
||
ifeq (,$(shell which conda)) | ||
HAS_CONDA=False | ||
else | ||
HAS_CONDA=True | ||
endif | ||
|
||
################################################################################# | ||
# COMMANDS # | ||
################################################################################# | ||
|
||
## Delete all compiled Python files | ||
clean: | ||
rm -rf htmlcov && make clean -C docs | ||
find . -type f -name "*.py[co]" -delete | ||
find . -type d -name "__pycache__" -delete | ||
|
||
## Apply black formatting | ||
black: | ||
black --exclude autometa/validation autometa | ||
|
||
## Set up python interpreter environment | ||
create_environment: | ||
ifeq (True,$(HAS_CONDA)) | ||
@echo ">>> Detected conda, creating conda environment." | ||
ifeq (3,$(findstring 3,$(PYTHON_INTERPRETER))) | ||
conda create --name $(PROJECT_NAME) python=3 | ||
else | ||
conda create --name $(PROJECT_NAME) python=2.7 | ||
endif | ||
@echo ">>> New conda env created. Activate with:\nsource activate $(PROJECT_NAME)" | ||
else | ||
$(PYTHON_INTERPRETER) -m pip install -q virtualenv virtualenvwrapper | ||
@echo ">>> Installing virtualenvwrapper if not already installed.\nMake sure the following lines are in shell startup file\n\ | ||
export WORKON_HOME=$$HOME/.virtualenvs\nexport PROJECT_HOME=$$HOME/Devel\nsource /usr/local/bin/virtualenvwrapper.sh\n" | ||
@bash -c "source `which virtualenvwrapper.sh`;mkvirtualenv $(PROJECT_NAME) --python=$(PYTHON_INTERPRETER)" | ||
@echo ">>> New virtualenv created. Activate with:\nworkon $(PROJECT_NAME)" | ||
endif | ||
|
||
################################################################################# | ||
# PROJECT RULES # | ||
################################################################################# | ||
|
||
## Install autometa from source | ||
install: | ||
python setup.py install | ||
$(PYTHON_INTERPRETER) setup.py install | ||
|
||
## Build docker image from Dockerfile (auto-taggged as jason-c-kwan/autometa:<current-branch>) | ||
image: Dockerfile | ||
docker build . -t jason-c-kwan/autometa:`git branch --show-current` | ||
|
||
## Build documentation for autometa.readthedocs.io | ||
docs: | ||
make clean html -C docs && open docs/build/html/index.html | ||
make clean html -C docs | ||
@echo "docs built. Open docs/build/html/index.html to view" | ||
|
||
clean: | ||
@echo "Removing everything under 'htmlcov'..." | ||
@rm -rf htmlcov && make clean -C docs | ||
## Download test_data.json for unit testing | ||
unit_test_data_download: | ||
gdown --id $(TEST_DATA_FILEID) -O tests/data/test_data.json | ||
|
||
## Build test_data.json file for unit testing (requires all files from https://drive.google.com/open?id=189C6do0Xw-X813gspsafR9r8m-YfbhTS be downloaded into tests/data/) | ||
unit_test_data_build: tests/data/records.fna | ||
$(PYTHON_INTERPRETER) make_test_data.py | ||
|
||
## Run all unit tests | ||
unit_test: tests/data/test_data.json | ||
$(PYTHON_INTERPRETER) -m pytest --durations=0 --cov=autometa --emoji --cov-report html | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am getting an error when I run
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make is correctly pointing out that you do not have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is your conda environment named |
||
|
||
## Run unit tests marked with WIP | ||
unit_test_wip: tests/data/test_data.json | ||
$(PYTHON_INTERPRETER) -m pytest -m "wip" --durations=0 --cov=autometa --emoji --cov-report html | ||
|
||
## Run unit tests marked with entrypoint | ||
unit_test_entrypoints: tests/data/test_data.json | ||
$(PYTHON_INTERPRETER) -m pytest -m "entrypoint" --durations=0 --cov=autometa --emoji --cov-report html | ||
|
||
test: tests/data/test_data.json | ||
python -m pytest --durations=0 --cov=autometa --emoji --cov-report html | ||
|
||
test-wip: tests/data/test_data.json | ||
python -m pytest -m "wip" --durations=0 --cov=autometa --emoji --cov-report html | ||
################################################################################# | ||
# Self Documenting Commands # | ||
################################################################################# | ||
|
||
test-entrypoints: tests/data/test_data.json | ||
python -m pytest -m "entrypoint" --durations=0 --cov=autometa --emoji --cov-report html | ||
.DEFAULT_GOAL := help | ||
|
||
.PHONY: hello docs clean test test-wip test-entrypoints | ||
# Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html> | ||
# sed script explained: | ||
# /^##/: | ||
# * save line in hold space | ||
# * purge line | ||
# * Loop: | ||
# * append newline + line to hold space | ||
# * go to next line | ||
# * if line starts with doc comment, strip comment character off and loop | ||
# * remove target prerequisites | ||
# * append hold space (+ newline) to line | ||
# * replace newline plus comments by `---` | ||
# * print line | ||
# Separate expressions are necessary because labels cannot be delimited by | ||
# semicolon; see <http://stackoverflow.com/a/11799865/1968> | ||
.PHONY: help | ||
help: | ||
@echo "$$(tput bold)Available rules:$$(tput sgr0)" | ||
@echo | ||
@sed -n -e "/^## / { \ | ||
h; \ | ||
s/.*//; \ | ||
:doc" \ | ||
-e "H; \ | ||
n; \ | ||
s/^## //; \ | ||
t doc" \ | ||
-e "s/:.*//; \ | ||
G; \ | ||
s/\\n## /---/; \ | ||
s/\\n/ /g; \ | ||
p; \ | ||
}" ${MAKEFILE_LIST} \ | ||
| LC_ALL='C' sort --ignore-case \ | ||
| awk -F '---' \ | ||
-v ncol=$$(tput cols) \ | ||
-v indent=19 \ | ||
-v col_on="$$(tput setaf 6)" \ | ||
-v col_off="$$(tput sgr0)" \ | ||
'{ \ | ||
printf "%s%*s%s ", col_on, -indent, $$1, col_off; \ | ||
n = split($$2, words, " "); \ | ||
line_length = ncol - indent; \ | ||
for (i = 1; i <= n; i++) { \ | ||
line_length -= length(words[i]) + 1; \ | ||
if (line_length <= 0) { \ | ||
line_length = ncol - indent - length(words[i]) - 1; \ | ||
printf "\n%*s ", -indent, " "; \ | ||
} \ | ||
printf "%s ", words[i]; \ | ||
} \ | ||
printf "\n"; \ | ||
}' \ | ||
| more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I tried
make image
which worked on my mac, then in the image, after doingapt-get install build-essential
ranmake unit_test_data_download
(which worked), I triedmake unit_test_data_build
, and I got this:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try
make unit_test
?make unit_test_data_build
is the first command to use if you were trying to rebuild thetest_data.json
object. This will aggregate all of the files found in the path linked to google drive in the docs.Perhaps for documentation
@Sidduppal
Building Autometa's unit tests
Relevant Makefile Commands
unit_test_data_build
unit_test_data_download
unit_test_wip
unit_test_entrypoints
unit_test
unit_test_data_build
This command is used to build the
test_data.json
file for unit testing. I.e. it will run the scriptmake_test_data.py
which will aggregate all of the files in thetests/data
folder (Note: the required files have been placed here https://drive.google.com/open?id=189C6do0Xw-X813gspsafR9r8m-YfbhTS and should be downloaded intotests/data/
). This is the first or perhaps 0th step when it comes to running the tests as it generates thetest_data.json
file that is parsed to retrieve all of the pre-generated variables used for intermediate stages of the pipeline. This is done to reduce the test time and computational workload when running through the test suite.As an example, running diamond BLAST is a stage in the pipeline, but we should not be testing whether diamond works, so we simply need to retrieve a "pre-diamond blasted table" and ensure our parser as well as subsequent steps are functioning appropriately. Therefore, the table is written into
test_data.json
and retrieved when the parser unit test is conducted. Decisions at this stage are somewhat fundamental and may have unintended side-effects across the rest of the test suite.unit_test_data_download
This command downloads the
test_data.json
object that was generated fromunit_test_data_build
and then uploaded to the autometa_test_data google drive. This provides convenience for someone wanting to run the test suite that requires the test variables constructed from the previous command. This is a necessary step when wanting to run unit tests as thetest_data.json
file will hold many of the variables necessary to conduct these tests.unit_test_wip
This command runs unit tests but only includes tests marked as work-in-progress (WIP). This is denoted in pytest with the decorator:
unit_test_entrypoints
This command runs unit tests but only includes tests marked as entrypoints. This is denoted in pytest with the decorator:
Entrypoints are basically the commands we will list out as 'console scripts' in
setup.py
that will be available as commands to the end user. These are important and sometimes referred to as "happy" tests because if one of these fail for the end-user, they will probably be quite unhappy and likely distrust the functionality of the rest of the codebase.unit_test
This command runs all unit tests under the
tests
directory. This includes all tests marked as WIP or as entrypoints. However this will skip tests marked with the decorator:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the above description, it is unclear whether you need to run
make unit_test_data_build
as well asmake unit_test_data_download
. I just pulled this PR, ranmake image
, then in the image successfully ranmake unit_test_data_download
. After that,make unit_test_data_build
gives me:make unit_test_wip
gives me:Then
make unit_test_entrypoints
gives me:I also get the same thing with
make unit_test
. Seems like there is something wrong with__main__.py
? Not sure what themake unit_test_data_build
error is all about.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pytest-variables
andpytest-cov
need to be installed. Iβve simplified this a bit more within the Makefile by adding the command:test_environment
. Now if you runmake unit_test
(or any of these that havetest_environment
as a dependency) it will install any requirements if they have not been installed prior to running the unit testsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I re-pulled, and then deleted my old docker image and re-built it. I ran
make test_environment
, which seemed to work fine, thenmake unit_test_data_download
, which also worked. But then when I triedmake unit_test_data_build
, I still get:I now get a bit further with
make unit_test_wip
. I get:I get a similar thing for
make unit_test_entrypoints
:This StackOverflow seems to suggest the last two problems are something to do with setting the working directory correctly. Really not sure what is going on with
make unit_test_data_build
.https://stackoverflow.com/questions/65394782/pytest-not-working-with-django-and-docker-assertionerror-local-dev-console
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressing
unit_test_data_build
unit_test_data_build
is not required for running unit tests. This is a one-time command if one plans to create a newtest_data.json
object. This would only be necessary if we are changing file formats or adding more objects into the test suite.The only commands you need to run the test suite are
unit_test_data_download
andunit_test{_wip,_entrypoints}
.You will continue to get the error:
If you do not download the entire directory within autometa_test_data/unit_test_data that contains records.fna as well as all of the other files that were used to create test_data.json.
Make is telling you that the file at the path
tests/data/records.fna
does not exists. This file is not downloaded withunit_test_data_download
. This file, as well as a number of other files in autometa_test_data/unit_test_data would need to be downloaded forunit_test_data_build
to function appropriately.Luckily, the user only needs the
test_data.json
file to run tests, so you can safely ignore the above command when performing unit tests for autometaThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I was able to run the tests using these instructions (and the last commit). Thanks!