From cd19aa5fdf1e73c3faddba0d1ccd84848aac226d Mon Sep 17 00:00:00 2001 From: Derek Brooks Date: Wed, 14 Sep 2022 16:50:18 -0500 Subject: [PATCH] enter: docker (#48) * enter: docker * Remove unnecessary dockerfile dependency. Update README. * Kill Dockerfile in favor of CLI --- .env-example | 3 ++ README.md | 85 +++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 67 insertions(+), 21 deletions(-) create mode 100644 .env-example diff --git a/.env-example b/.env-example new file mode 100644 index 00000000..887d7f1d --- /dev/null +++ b/.env-example @@ -0,0 +1,3 @@ +ROBOFLOW_API_KEY=your-roboflow-private-api-key +PROJECT_NAME=your-project-name +PROJECT_VERSION=1 diff --git a/README.md b/README.md index f2d98a2e..cd6b3ad0 100644 --- a/README.md +++ b/README.md @@ -87,41 +87,84 @@ Selecting the format you'd like your project to be exported as while choosing th ![Alt Text](https://media.giphy.com/media/I5g06mUnVzdX7iT2Gf/giphy.gif) -## Deving locally -1. clone repo -2. create a virtual env: `virtualenv local_dev` -3. activate virtual env: `source local_dev/bin/activate` -4. install packages from repo: `pip3 install -e ".[dev]"` -5. create script on top level of `ROBOFLOW-PYTHON` and reference local `roboflow` directory: `from roboflow import Roboflow` -6. when done, uptick the pip package minor version number in `setup.py` -7. manually add any new dependencies to the `requirements.txt` and list of dependencies in `setup.py` (careful not to overwrite any packages that might screw up backwards dependencies for object detection, etc.) +## Developing locally -### Code Quality +### Using Docker -We provide a `Makefile` to format and ensure code quality. **Be sure to run them before creating a PR**. +To set the Docker container up for the first time: + +```bash +# Clone this repo +git clone git@github.com:roboflow-ai/roboflow-python.git && cd roboflow-python + +# Copy the environment variables template +# Be sure to update the values with your account's information +cp .env-example .env +# Build and run a new docker container image +docker run -it -v $(pwd):/roboflow --name roboflow python:3.8.14-slim /bin/bash + +# Install Dependencies +cd roboflow/ && pip install -e ".[dev]" + +# Run tests +python -m unittest ``` -# format your code with `black` and `isort` run -make style -# check code with flake8 -make check_code_quality + +Running the Docker container after initial build: + +```bash +docker start roboflow +docker exec -it roboflow /bin/bash +cd roboflow/ && python -m unittest ``` -**Note** This tests will be run automatically when you commit thanks to git hooks. +### Using Virtualenv + +```bash +# Clone this repo +git clone git@github.com:roboflow-ai/roboflow-python.git && cd roboflow-python + +# create virtual env +virtualenv local_dev -### Tests +# activate virtual env +source local_dev/bin/activate -You need to have the following `env` variables, +# install dependencies +pip3 install -e ".[dev]" +``` + +### Testing + +You need to have the following `env` variables defined. If using docker along with the `.env` file, these will be automatically defined. ``` -ROBOFLOW_API_KEY="" +ROBOFLOW_API_KEY="" PROJECT_NAME="" -PROJECT_VERSION="" # by default "1" +PROJECT_VERSION="1" ``` -Then, assuming you have installed the `dev` packages (`pip install -e ".[dev]`), you can run the tests +Run tests: ```bash - python -m unittest ``` + +### Contributing + +1. Increment the pip package minor version number in `setup.py` +1. Manually add any new dependencies to `requirements.txt` and list of dependencies in `setup.py` (Be careful not to overwrite any packages that might screw up backwards dependencies for object detection, etc.) + +### Code Quality + +We provide a `Makefile` to format and ensure code quality. **Be sure to run them before creating a PR**. + +``` +# format your code with `black` and `isort` run +make style +# check code with flake8 +make check_code_quality +``` + +**Note** These tests will be run automatically when you commit thanks to git hooks.