2022-03-16 17:31:38 +03:00
|
|
|
# Make commands for the toolbox users
|
|
|
|
|
|
|
|
# Create a Conda environment for use with both the hi-ml and hi-ml-azure folder
|
|
|
|
env:
|
2022-05-06 16:03:35 +03:00
|
|
|
conda env create --file hi-ml/environment.yml
|
2022-03-16 17:31:38 +03:00
|
|
|
|
|
|
|
# Make commands that are used in the build pipeline
|
|
|
|
|
2021-09-22 19:56:35 +03:00
|
|
|
# call make for each sub package
|
|
|
|
define call_packages
|
2023-03-21 12:21:09 +03:00
|
|
|
cd hi-ml && $(MAKE) $(1)
|
2021-09-22 19:56:35 +03:00
|
|
|
cd hi-ml-azure && $(MAKE) $(1)
|
2023-03-21 12:21:09 +03:00
|
|
|
cd hi-ml-cpath && $(MAKE) $(1)
|
|
|
|
cd hi-ml-multimodal && $(MAKE) $(1)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define call_pip_packages
|
2021-09-22 19:56:35 +03:00
|
|
|
cd hi-ml && $(MAKE) $(1)
|
2023-03-21 12:21:09 +03:00
|
|
|
cd hi-ml-azure && $(MAKE) $(1)
|
2021-09-22 19:56:35 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
## Package management
|
|
|
|
|
2024-06-28 13:12:00 +03:00
|
|
|
# pip upgrade.
|
|
|
|
# As of PIP version 24.1, conditions like ">1.8.*" are no longer supported, but pytorch lightning
|
|
|
|
# in the version we are using is still using this syntax. So we need to restrict the pip versions.
|
2021-08-20 18:20:27 +03:00
|
|
|
pip_upgrade:
|
2024-06-28 13:12:00 +03:00
|
|
|
python -m pip install --upgrade "pip<24.1"
|
2021-08-20 18:20:27 +03:00
|
|
|
|
2021-09-22 19:56:35 +03:00
|
|
|
# pip upgrade and install build requirements
|
2021-08-20 18:20:27 +03:00
|
|
|
pip_build: pip_upgrade
|
2021-07-23 13:10:21 +03:00
|
|
|
pip install -r build_requirements.txt
|
2021-08-20 18:20:27 +03:00
|
|
|
|
2021-09-22 19:56:35 +03:00
|
|
|
# pip upgrade and install test requirements
|
2021-08-20 18:20:27 +03:00
|
|
|
pip_test: pip_upgrade
|
2021-07-23 13:10:21 +03:00
|
|
|
pip install -r test_requirements.txt
|
2021-08-20 18:20:27 +03:00
|
|
|
|
2021-10-26 16:50:22 +03:00
|
|
|
# pip install local packages in editable mode for development and testing
|
2021-09-22 19:56:35 +03:00
|
|
|
call_pip_local:
|
2023-03-21 12:21:09 +03:00
|
|
|
$(call call_pip_packages,call_pip_local)
|
2021-09-22 19:56:35 +03:00
|
|
|
|
2021-10-26 16:50:22 +03:00
|
|
|
# pip upgrade and install local packages in editable mode
|
2021-09-22 19:56:35 +03:00
|
|
|
pip_local: pip_upgrade call_pip_local
|
2021-07-19 17:01:05 +03:00
|
|
|
|
2021-08-20 18:20:27 +03:00
|
|
|
# pip install everything for local development and testing
|
2021-09-22 19:56:35 +03:00
|
|
|
pip: pip_build pip_test call_pip_local
|
2021-08-20 18:20:27 +03:00
|
|
|
|
2022-02-15 19:22:04 +03:00
|
|
|
|
2021-10-26 16:50:22 +03:00
|
|
|
# update current conda environment
|
|
|
|
conda_update:
|
2022-05-06 16:03:35 +03:00
|
|
|
conda env update -n $(CONDA_DEFAULT_ENV) --file hi-ml/environment.yml
|
2021-10-18 18:54:00 +03:00
|
|
|
|
2022-02-15 19:22:04 +03:00
|
|
|
# Set the conda environment for local development work, that contains all packages need for hi-ml, hi-ml-azure
|
2022-07-18 15:40:47 +03:00
|
|
|
# and hi-ml-cpath with hi-ml and hi-ml-azure installed in editable mode
|
2021-10-26 16:50:22 +03:00
|
|
|
conda: conda_update call_pip_local
|
2021-08-04 19:29:40 +03:00
|
|
|
|
2021-09-22 19:56:35 +03:00
|
|
|
## Actions
|
|
|
|
|
|
|
|
# clean build artifacts
|
|
|
|
clean:
|
2023-01-17 13:43:55 +03:00
|
|
|
rm -rf ./.mypy_cache ./.pytest_cache ./coverage ./logs ./outputs
|
|
|
|
rm -f ./coverage.txt ./coverage.xml ./most_recent_run.txt
|
2021-09-22 19:56:35 +03:00
|
|
|
$(call call_packages,clean)
|
|
|
|
|
|
|
|
# build package, assuming build requirements already installed
|
|
|
|
call_build:
|
2023-03-21 12:21:09 +03:00
|
|
|
$(call call_pip_packages,call_build)
|
2021-07-23 13:10:21 +03:00
|
|
|
|
2021-09-22 19:56:35 +03:00
|
|
|
# pip install build requirements and build package
|
|
|
|
build: pip_build call_build
|
|
|
|
|
|
|
|
# run flake8, assuming test requirements already installed
|
2023-01-11 18:48:21 +03:00
|
|
|
flake8:
|
|
|
|
$(call call_packages,flake8)
|
2021-09-22 19:56:35 +03:00
|
|
|
|
|
|
|
# run mypy, assuming test requirements already installed
|
2023-01-11 18:48:21 +03:00
|
|
|
mypy:
|
|
|
|
$(call call_packages,mypy)
|
2021-08-04 19:29:40 +03:00
|
|
|
|
2023-03-21 12:21:09 +03:00
|
|
|
# run black styling, assuming test requirements already installed
|
|
|
|
black:
|
|
|
|
$(call call_packages,black)
|
|
|
|
|
2021-10-18 18:54:00 +03:00
|
|
|
# run pyright, assuming test requirements already installed
|
|
|
|
call_pyright:
|
|
|
|
npm install -g pyright
|
2021-10-21 17:23:25 +03:00
|
|
|
pyright
|
2021-10-18 18:54:00 +03:00
|
|
|
|
2021-10-26 16:50:22 +03:00
|
|
|
# conda install test requirements and run pyright
|
|
|
|
pyright: conda call_pyright
|
2021-10-18 18:54:00 +03:00
|
|
|
|
2023-01-11 18:48:21 +03:00
|
|
|
# run basic checks, assuming test requirements already installed
|
2023-03-21 12:21:09 +03:00
|
|
|
check: flake8 mypy black
|
2021-07-19 17:01:05 +03:00
|
|
|
|
2021-09-22 19:56:35 +03:00
|
|
|
# run pytest on package, assuming test requirements already installed
|
2023-01-11 18:48:21 +03:00
|
|
|
pytest:
|
|
|
|
$(call call_packages,pytest)
|
2021-08-20 18:20:27 +03:00
|
|
|
|
2021-09-22 19:56:35 +03:00
|
|
|
# run pytest fast subset on package, assuming test requirements already installed
|
2023-01-11 18:48:21 +03:00
|
|
|
pytest_fast:
|
2023-03-21 12:21:09 +03:00
|
|
|
$(call call_pip_packages,pytest_fast)
|
2021-08-20 18:20:27 +03:00
|
|
|
|
2021-09-22 19:56:35 +03:00
|
|
|
# run pytest with coverage on package, and format coverage output as a text file, assuming test requirements already installed
|
|
|
|
call_pytest_and_coverage:
|
2023-03-21 12:21:09 +03:00
|
|
|
$(call call_pip_packages,call_pytest_and_coverage)
|
2021-07-23 13:10:21 +03:00
|
|
|
|
2021-09-22 19:56:35 +03:00
|
|
|
# install test requirements and run pytest coverage
|
|
|
|
pytest_and_coverage: pip_test call_pytest_and_coverage
|
2021-07-27 17:16:28 +03:00
|
|
|
|
2021-09-22 19:56:35 +03:00
|
|
|
# install test requirements and run all tests
|
2023-04-06 15:00:24 +03:00
|
|
|
test_all: pip_test flake8 mypy call_pytest_and_coverage
|
2021-08-16 16:51:38 +03:00
|
|
|
|
2021-09-27 11:29:58 +03:00
|
|
|
# build the github format_coverage action
|
|
|
|
action:
|
|
|
|
cd .github/actions/format_coverage && ncc build index.js --license licenses.txt
|
|
|
|
|
|
|
|
combine: pip_test
|
|
|
|
mkdir -p coverage
|
|
|
|
cp hi-ml/.coverage coverage/hi-ml-coverage
|
|
|
|
cp hi-ml-azure/.coverage coverage/hi-ml-azure-coverage
|
2022-07-18 15:40:47 +03:00
|
|
|
cp hi-ml-cpath/.coverage coverage/hi-ml-cpath-coverage
|
2022-02-03 12:12:58 +03:00
|
|
|
cp .coveragerc coverage/
|
2021-09-27 11:29:58 +03:00
|
|
|
cd coverage && \
|
2022-07-18 15:40:47 +03:00
|
|
|
coverage combine hi-ml-coverage hi-ml-azure-coverage hi-ml-cpath-coverage && \
|
2021-09-27 11:29:58 +03:00
|
|
|
coverage html && \
|
|
|
|
coverage xml && \
|
|
|
|
pycobertura show --format text --output coverage.txt coverage.xml
|
2024-06-28 13:12:00 +03:00
|
|
|
|
|
|
|
blobfuse:
|
|
|
|
setup/prepare_blobfuse_installation.sh
|
|
|
|
sudo apt-get install blobfuse fuse
|
|
|
|
|
|
|
|
mount:
|
|
|
|
setup/mount_datastores.sh
|