-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
[travis/tox] Restructuring configuration and testing #4552
[travis/tox] Restructuring configuration and testing #4552
Conversation
827d844
to
75589db
Compare
Codecov Report
@@ Coverage Diff @@
## master #4552 +/- ##
=======================================
Coverage 72.63% 72.63%
=======================================
Files 205 205
Lines 15403 15403
Branches 1183 1183
=======================================
Hits 11188 11188
Misses 4212 4212
Partials 3 3
Continue to review full report at Codecov.
|
969a338
to
c086986
Compare
e4e1c55
to
5c69cce
Compare
0cdaff4
to
cbbf647
Compare
@mistercrunch @betodealmeida per the conservation regarding pinning earlier today what are your thoughts on this PR? Note beyond |
683061c
to
8254499
Compare
@mistercrunch sorry I was wondering what your thoughts were on this? Additionally having a |
So if I want to add a python dep where do I do it? In setup.py AND in requirements.txt? I was thinking this process would involve a [documented] pip-compile step and the whole dep tree. I remember we spoke about this but forgot the details on why no pip-compile + pinning the whole tree. If the goal is to get as close as possible to an fully reproducible build, it seems like we need the whole dep tree. |
8254499
to
af9241e
Compare
@mistercrunch I definitely explored the The issue is there's not a plausible way to autogenerate a Python 2/3 compatible
however if you try to install this in Python 3 via,
I thought of two possible solutions:
I raised this issue with |
@mistercrunch @john-bodley Would (pipenv)[https://docs.pipenv.org/] solve our problems here? |
Also I'm not clear on how Pypi operates, but my guess is that it only looks at what's in At Lyft our build process for all Python apps generates both a |
@mistercrunch it would be good to understand how Lyft creates these different files (though your hypothesis seems valid). It seems you maybe able to achieve this in conjunction with pyenv. I can also explore pipenv, though it would need to play well with tox, Travis, etc. Also if we went down the virtualenv route one would need to activate it for the various services or wrap existing command via pipenv run. Finally the setup.py/requirements.txt relationship is well defined, in essence setup.py should never pin packages but merely provide the list of required dependencies, with version restrictions were appropriate. I realize that Superset is an application rather than a package, but this allows individual instances to configure their Python environment how they see appropriate, i.e., a custom plugin may require a different version of dependency. The requirements.txt simply provides a deterministic environment using package versions which we’ve certified/tested. |
198bc7f
to
0d3765f
Compare
0d3765f
to
9ecb70c
Compare
@mistercrunch per our conversation last week, I updated |
LGTM! |
(cherry picked from commit 1627fd0)
TL;DR this PR changes the way we configure and test the application. I know there are mixed options about the primary use case of
tox
(#3881), but I thought it was worthwhile exploring.tox
I think of
tox
as a testing environment which can run locally via shell-based testing or with a CI server, and thus should be agnostic of the CI service. In my opinion the way we test locally and remotely should be the same. This helps to reinforce familiarity and consistency. I agree there is some additional overhead when the environment is first created, but future runs leverage the existing environment (it can be recreated if necessary viatox --recreate
) which is built in a deterministic manner whilst guaranteeing all the dependencies are met. All tests (including unit and linting) should be run viatox
rather than executingflake8
,npm run lint
etc.Caching
Modern versions of
pip
fetch the wheel file from PyPI if it exists (or builds it if it doesn't) and caches it locally, and thus there's no longer a need for thepip wheel
logic, which helps to simplify thetox
environment. Note the Travis CI leverages thepip
cache.Python unit tests
Previously for unit testing locally one would run,
which used a slew of globally defined SQLite databases which resided in
~/.superset
. These databases are re-created every time the script is re-run. Withtox
one simply runs,which uses a self contained Python version specific virtual environment which houses the SQLite databases. These are stored in a
tox
environment temporary directory which are re-created on each test run in a similar manner to before.Previously when running a single unit test one would first have to run all the tests, in order to create the databases, populate the data etc., however here this requirement is loosened. Rather than running,
one would use the same
tox
test harness and run,Now you one can run either i) all tests in a specific file, or ii) a single test, without having to run the entire test suite first. Every time one re-runs the tests, the
tox
environment persists, however the main database is re-created/re-populated only if needed (not all tests require the database). Though there is some potential overhead it does ensure that the database state is valid before each relevant test run.Reformatting
Finally there are a few other more minor changes to the
tox
configuration including; new tox multi-dimensional platform-specific configuration, removing unnecessary installs, and fixing the MySQL Python 3.4SUPERSET__SQLALCHEMY_DATABASE_URI
environment variable.requirements.txt
I realize that Superset is an application rather than a library but when defining Python packages
setup.py
should only contain abstract dependencies as described in detail here. Decoupling the actual requirements fromsetup.py
means individual deployments have the freedom to use other versions, whereas from a development standpoint you want to have builds which are predictable and deterministic.The pinned versions from
setup.py
have been removed and added to arequirements.txt
file, which is used bytox
. Similarly development and documentation requirements have been pinned. Note I explore options such aspip-compile
from pip-tools which can generate requirement files fromsetup.py
or other config files. Though this seemed promising, it pins all sub-dependencies as well which can be problematic as some of these packages are not defined in every Python version. At the moment it seems prudent to manage these files by hand.setup.py
As stated previous all pinning has been removed from
setup.py
and all packages are now listed in alphabetical order, and lower cased. Additionally I've removed thetest_requires
aspython setup.py tests
is both discouraged and unused as tests were never run this way.Travis
Only minor changes to the
.travis.yml
file, deprecatedtox-travis
's which wasn't used, simplifying the environment matrix to be a list of environments (which set the TravisTOXENV
environment), explicitly defining all the services, leveraging the pip cache (see previously) and removing/tmp/hive/bin
from thePATH
which I believe may have been copied from Airflow's .travis.yml file.to: @mistercrunch @xrmx