databricks / spark-deep-learning

Deep Learning Pipelines for Apache Spark
https://databricks.github.io/spark-deep-learning
Apache License 2.0
1.99k stars 494 forks source link

Dev scripts #118

Closed yogeshg closed 6 years ago

yogeshg commented 6 years ago

Motivation

Developers need to run several tools and setting these up could be a hassle. These tools include but are not limited to setting up the environment, running style checks, running tests etc. For different projects, these tools may have different default values.

Documentation is needed for these default values to allow users to run these tools. But we never read documentation, so an interactive script with default values and options to run these tools in a limited scope might be useful. Limited scope might mean only the files changed, different python or spark versions etc.

Tools like pylint, prospector etc. do a great job of giving users flexibility, but they are mostly run with the default values. They also do not give options to run on only currently touched files -- this defintion is also broad.

This is why we might want a script to help the user do everything they need and also guide them through the process through "--help" and autocomplete options. It should also be easy for us to maintain such a script and users to read it to see what goes on under the hood. Luckily for us python argh package uses parseargs and argscomplete packages to expose python functions on bash with great help and autocompletion funcitonality.

Demo

$ pip install -r python/dev-requirements.txt
## installs all requirements for development

$ ./python/run.py -h
## shows help for project
# positional arguments:
#   {pylint,prospector,unittest,nose,envsetup}
#     pylint              calls pylint with a limited set of keywords. run
#                         `pylint --help` for more details.
#     prospector          calls prospector with a limited set of keywords. run
#                         `prospector --help` for more details.
#     unittest            calls unittest with a limited set of keywords. run
#                         `python -m unittest --help` for more details.
#     nose                calls nosettest with a limited set of keywords. run
#                         `python -m nose --help` for more details.
#     envsetup            Prints out shell commands that can be used in terminal
#                         to setup the environment. This tool inspects the
#                         current environment, adds default values, and/or
#                         interactively asks user for values and prints all or
#                         the missing variables that need to be set. :param
#                         default: if default values should be set in this
#                         script or not :param interactive: if user should be
#                         prompted for values or not :param missing_only: if
#                         only missing variable should be printed :param
#                         verbose: if user should be guided or not
# 
# optional arguments:
#   -h, --help            show this help message and exit

$ ./python/run.py envsetup -d -i
## interactively setup or default the required environment variables
## this can be copied by user into their shell script or,

$ eval $(./python/run.py envsetup -d -i)
## directly used in the current bash

$ ./python/run.py pylint
## runs pylint with project specific rc-files on full python code path or "currently touched files"

$ ./python/run.py test
## runs all required tests or those for "currently touched files"

Tools

Misc:

codecov-io commented 6 years ago

Codecov Report

Merging #118 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #118   +/-   ##
=======================================
  Coverage   85.38%   85.38%           
=======================================
  Files          33       33           
  Lines        1923     1923           
  Branches       44       44           
=======================================
  Hits         1642     1642           
  Misses        281      281

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9f05fc2...c6bdd8a. Read the comment docs.

yogeshg commented 6 years ago

This pr was split into #121 and #124