diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e620e6afe8..680f4f198c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -294,7 +294,17 @@ python setup.py build_sphinx ### Flask server -Make sure your machine meets the [OS dependencies](https://superset.incubator.apache.org/installation.html#os-dependencies) before following these steps. +#### OS Dependencies + +Make sure your machine meets the [OS dependencies](https://superset.incubator.apache.org/installation.html#os-dependencies) before following these steps. + +Developers should use a virtualenv. + +``` +pip install virtualenv +``` + +Then proceed with: ```bash # Create a virtual environemnt and activate it (recommended) @@ -304,10 +314,11 @@ source venv/bin/activate # Install external dependencies pip install -r requirements.txt pip install -r requirements-dev.txt + # Install Superset in editable (development) mode pip install -e . -# Create an admin user +# Create an admin user in your metadata database fabmanager create-admin --app superset # Initialize the database @@ -319,11 +330,10 @@ superset init # Load some data to play with superset load_examples -# Start the Flask dev web server from inside the `superset` dir at port 8088 +# Start the Flask dev web server from inside your virtualenv. # Note that your page may not have css at this point. # See instructions below how to build the front-end assets. -cd superset -FLASK_ENV=development flask run -p 8088 --with-threads --reload --debugger +FLASK_ENV=development superset run -p 8088 --with-threads --reload --debugger ``` #### Logging to the browser console @@ -355,7 +365,14 @@ app.logger.info(form_data) Frontend assets (JavaScript, CSS, and images) must be compiled in order to properly display the web UI. The `superset/assets` directory contains all NPM-managed front end assets. Note that there are additional frontend assets bundled with Flask-Appbuilder (e.g. jQuery and bootstrap); these are not managed by NPM, and may be phased out in the future. -First, be sure you are using recent versions of NodeJS and npm. Using [nvm](https://github.com/creationix/nvm) to manage them is recommended. +#### nvm and node + +First, be sure you are using recent versions of NodeJS and npm. Using [nvm](https://github.com/creationix/nvm) to manage them is recommended. Check the docs at the link to be sure, but at the time of writing the following would install nvm and node: + +```bash +curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash +nvm install node +``` #### Prerequisite @@ -396,6 +413,12 @@ npm run dev npm run prod ``` +If you run this service from somewhere other than your local machine, you may need to add hostname value to webpack.config.js at .devServer.public specifying the endpoint at which you will access the app. For example: myhost:9001. For convenience you may want to install webpack, webpack-cli and webpack-dev-server globally so that you can run them directly: + +```bash +npm install --global webpack webpack-cli webpack-dev-server +``` + #### Updating NPM packages Use npm in the prescribed way, making sure that @@ -517,14 +540,15 @@ superset db upgrade superset init superset load_test_users superset load_examples -superset runserver +superset run --port 8081 ``` Run Cypress tests: ```bash -cd /superset/superset/assets +cd superset/assets npm run build +npm run install-cypress npm run cypress run # run tests from a specific file @@ -534,6 +558,8 @@ npm run cypress run -- --spec cypress/integration/explore/link.test.js npm run cypress run -- --spec cypress/integration/dashboard/index.test.js --config video=true ``` +See [`superset/assets/cypress_build.sh`](https://github.com/apache/incubator-superset/blob/master/superset/assets/cypress_build.sh). + ## Translating We use [Babel](http://babel.pocoo.org/en/latest/) to translate Superset. In Python files, we import the magic `_` function using: diff --git a/contrib/docker/README.md b/contrib/docker/README.md new file mode 100644 index 0000000000..0c3146f7e7 --- /dev/null +++ b/contrib/docker/README.md @@ -0,0 +1,58 @@ + + +# Getting Start with Superset using Docker + +Docker is an easy way to get stated with Superset. + +## Initializing Database + +To initialize the database with a user and example charts, dashboards and datasets run: + +```bash +SUPERSET_LOAD_EXAMPLES=yes docker-compose run --rm superset ./docker-init.sh +``` + +This may take a minute. + +## Normal Operation + +To run the container, simply run: + +```bash +docker-compose up +``` + +After several minutes for superset initialization to finish, you can open a browser and view [`http://localhost:8088`](http://localhost:8088) +to start your journey. + +## Developing + +While running, the container server will reload on modification of the superset python and javascript source code. +Don't forget to reload the page to take the new frontend into account though. + +## Production + +It is also possible to run Superset in non-development mode: in the `docker-compose.yml` file remove +the volumes needed for development and change the variable `SUPERSET_ENV` to `production`. + +## Resource Constraints + +If you are attempting to build on a Mac and it exits with 137 you need to increase your docker resources. +OSX instructions: https://docs.docker.com/docker-for-mac/#advanced (Search for memory) diff --git a/docs/installation.rst b/docs/installation.rst index 82459c7c53..329debc8a0 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -91,6 +91,8 @@ OSX instructions: https://docs.docker.com/docker-for-mac/#advanced (Search for m Or if you're curious and want to install superset from bottom up, then go ahead. +See also `contrib/docker/README.md `_ + OS dependencies --------------- @@ -121,7 +123,13 @@ that the required dependencies are installed: :: sudo yum upgrade python-setuptools sudo yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel -**OSX**, system python is not recommended. brew's python also ships with pip :: +**Mac OS X** If possible, you should upgrade to the latest version of OS X as issues are more likely to be resolved for that version. +You *will likely need* the latest version of XCode available for your installed version of OS X. You should also install +the XCode command line tools: :: + + xcode-select --install + +System python is not recommended. Homebrew's python also ships with pip: :: brew install pkg-config libffi openssl python env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography==2.4.2 @@ -184,8 +192,7 @@ Follow these few simple steps to install Superset.:: superset init # To start a development web server on port 8088, use -p to bind to another port - flask run -p 8080 --with-threads --reload --debugger - + superset run -p 8080 --with-threads --reload --debugger After installation, you should be able to point your browser to the right hostname:port `http://localhost:8088 `_, login using @@ -219,10 +226,8 @@ Refer to the `Gunicorn documentation `_ for more information. -Note that *gunicorn* does not -work on Windows so the `superset runserver` command is not expected to work -in that context. Also, note that the development web -server (`superset runserver -d`) is not intended for production use. +Note that the development web +server (`superset run` or `flask run`) is not intended for production use. If not using gunicorn, you may want to disable the use of flask-compress by setting `ENABLE_FLASK_COMPRESS = False` in your `superset_config.py` diff --git a/requirements-dev.txt b/requirements-dev.txt index 857b9ad07d..4b08ec4e43 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -23,7 +23,7 @@ flake8==3.6.0 flask-cors==3.0.6 ipdb==0.11 mypy==0.670 -mysqlclient==1.3.13 +mysqlclient==1.4.2.post1 nose==1.3.7 pip-tools==3.5.0 psycopg2-binary==2.7.5