This repository contains the description and code for setting up DVC to use a remote computer server using dask. Note that this use case relay on the original DVC tutorial and its code found here https://dvc.org/doc/tutorial.
The use case have the following prerequisites:
- A remote server with:
- SSH installed.
- A unix user you have the username and password for.
- A folder for your remote shared DVC cache, my is at
/scratch/dvc_project_cache/
. - A folder for your remote DVC data directories, my is at
/scratch/dvc_users/[REMOTE_USERNAME]/
. - A Dask scheduler installed and running at port 8786, see http://docs.dask.org/en/latest/setup.html for a guide.
- A MLflow tracking server installed and running at host 0.0.0.0 and port 5000, with
mlflow server --host 0.0.0.0 --file-store /projects/mlflow_runs/
.
- A local SSH keyfile (
ssh-keygen
), which have been copied to the remote server, withssh-copy-id [REMOTE_USERNAME]@[REMOTE_IP]
. - An open SSH port-forward to the Dask scheduler and MLflow tracking server from your local machine to the remote server, with
ssh -L 8786:[REMOTE_USERNAME]@[REMOTE_IP]:8786 -L 5000:[REMOTE_USERNAME]@[REMOTE_IP]:5000 [REMOTE_USERNAME]@[REMOTE_IP]
. - Set up local DVC development repository (following https://dvc.org/doc/user-guide/contributing/) with a conda environment:
- Fork https://github.com/iterative/dvc on Github.
git clone [email protected]:<GITHUB_USERNAME>/dvc.git
cd dvc
conda create -n py36_open_source_dvc python=3.6
conda activate py36_open_source_dvc
pip install -r requirements.txt
pip install -r tests/requirements.txt
pip install -e .
pip install pre-commit
pre-commit install
which dvc
should say[HOME]/anaconda3/envs/py36_open_source_dvc/bin/dvc
anddvc --version
should say the exact version available in you local DVC development repository.
- Configure you DVC globally (e.g. using the
--global
flag) for you local machine - note that I call my remote server "ahsoka":conda activate py36_open_source_dvc
dvc remote add ahsoka ssh://[REMOTE_IP]/ --global
dvc remote modify ahsoka user [REMOTE_USERNAME] --global
dvc remote modify ahsoka port 22 --global
dvc remote modify ahsoka keyfile [PATH_TO_YOUR_PUBLIC_SSH_KEY] --global
dvc remote add ahsoka_user_workspace remote://ahsoka/scratch/dvc_users/[REMOTE_USERNAME]/ --global
- These globally configured DVC remotes are used by the DVC config file in the Git repository, see
.dvc/config
, to specify project specific remotes for the DVC cache and DVC data workspace.
This use case of DVC and Dask has been set up as follow.
On your local machine do the following:
- Clone this test repository from my Github:
git clone [email protected]:PeterFogh/dvc_dask_use_case.git
- Install the Conda environment for this repository - note the new enviroment must point to your local DVC development repository:
conda env create -f conda_env.yml
, which have been create by the following commands (executed the 26-04-2019):conda create --name py36_open_source_dvc_dask_use_case --clone py36_open_source_dvc
conda install -n py36_open_source_dvc_dask_use_case dask scikit-learn
conda activate py36_open_source_dvc_dask_use_case && pip install mlflow matplotlib
conda env export -n py36_open_source_dvc_dask_use_case > conda_env.yml
- Check dvc version matches your development repository version:
conda activate py36_open_source_dvc && which dvc && dvc --version
andconda activate py36_open_source_dvc_dask_use_case && which dvc && dvc --version
- Reproduce the DVC pipeline:
dvc repro
- which have been specified by the following DVC stages:conda activate py36_open_source_dvc_dask_use_case
dvc run -d download_xml.py -d conf.py -o remote://ahsoka_project_data/download_xml/ -f download_xml.dvc python download_xml.py
dvc run -d xml_to_tsv.py -d conf.py -d remote://ahsoka_project_data/download_xml/ -o remote://ahsoka_project_data/xml_to_tsv/ -f xml_to_tsv.dvc python xml_to_tsv.py
dvc run -d split_train_test.py -d conf.py -d remote://ahsoka_project_data/xml_to_tsv/ -o remote://ahsoka_project_data/split_train_test/ -f split_train_test.dvc python split_train_test.py
dvc run -d featurization.py -d conf.py -d remote://ahsoka_project_data/split_train_test/ -o remote://ahsoka_project_data/featurization/ -f featurization.dvc python featurization.py
dvc run -d train_model.py -d conf.py -d remote://ahsoka_project_data/featurization/ -o remote://ahsoka_project_data/train_model/ -f train_model.dvc python train_model.py
dvc run -d evaluate.py -d conf.py -d remote://ahsoka_project_data/featurization/ -d remote://ahsoka_project_data/train_model/ -o remote://ahsoka_project_data/evaluate/ -m eval.txt -f Dvcfile python evaluate.py
- Show DVC metrics
dvc metrics show -a
. - Visit MLflow tracking server webUI from your local browser at http://localhost:5000/ to see the results of the pipeline.
- MLflow artifacts do not support our SSH setup.
mlflow.log_artifacts()
do not support files saved on the remote server. Artifact files must be located at a directory shared by both the client machine and the server using the methods described here. Read mlflow/mlflow#572 (comment) for more details on the problem. However, we can circumvent this problem using Dask to executed the MLflow run on the remote server. Thereby, both the client and the MLflow tracking server has not problem reading and writing to the same folder, as the they are executed on the same machine.