-
Notifications
You must be signed in to change notification settings - Fork 3
Development Environment Setup
- Get the Cockpit Source Code
- Get the Hyrise Database ready
- Install script
- Install manually
- Using the development environment
- Quick Fix
You have two options to set up the development environment:
- Use the
install_dependencies_development
script - Install everything that needed manually
- Clone the repository:
git clone https://github.com/hyrise/Cockpit.git
- Enter the Cockpit directory:
cd Cockpit
Please check out the following guide:
https://github.com/hyrise/Cockpit/wiki/Hyrise-Things
The install script will set up the development environment. Simply run:
./install_dependencies_development.sh
The script will install all packages (python, node), influxdb and set up a pipenv (https://github.com/pypa/pipenv).
First of all, you need to set up an influx database:
macOS
brew install influxdb
Ubuntu
wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/lsb-release
echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update && sudo apt-get install -y influxdb
sudo service influxdb start
You can install all needed packages with the following commands:
macOS
brew install python3.8 \
&& brew install libpq \
&& brew install postgresql
Ubuntu
# Install dependencies
sudo apt-get update
sudo apt-get install -y \
python3.8 \
python3.8-dev \
python3.8-distutils \
python3-pip \
wget \
curl \
git
We are using pipenv as a developer environment. To install pipenv run the following commands:
python3.8 -m pip install pipenv \
&& pipenv install --python 3.8 \
Run the following commands to bootstrap your developer environment.
pipenv sync --dev
# Please make sure you enable the pre-commit hooks:
pipenv run pre-commit install
The frontend part uses the Vue Composition API (https://composition-api.vuejs.org/), TypeScript (https://www.typescriptlang.org/) and Vuetify as Material Design Framework (https://vuetifyjs.com/de-DE/).
To get the frontend running we first need to install npm:
macOS
brew install node
Ubuntu
curl -sL https://deb.nodesource.com/setup_current.x | sudo -E bash -
sudo apt-get install -y nodejs
Before starting the server, you need to locally install all dependencies of the project by running:
cd hyrisecockpit/frontend && npm install && npm audit fix
To connect to a running backend, you need to create a .env
file in the frontend top level folder with your custom configuration. An example structure can be found in .env.example
. To reset your config to the default connection or create a .env
with the default values just run npm run reset:config
.
For the backend development (all python code) we are using pipenv
(https://github.com/pypa/pipenv).
pipenv
aims to combine Pipfile
, pip
and virtualenv
into one command on the command-line. The virtualenv directory typically gets placed in ~/.local/share/virtualenvs/XXX
, with XXX
being a hash of the path of the project directory. This is different from virtualenv
, where the directory is typically in the current working directory. pipenv
is meant to be used when developing Python applications (as opposed to libraries).
You ca access the virtual environment created by pipenv
via the command pipenv shell
. In this environment you can run the console scripts from the setup.py
file to start the components. You can run (by just typing in the command line):
-
cockpit-backend
to start the WSGI component (Flask). -
cockpit-manager
to start the manager component. -
cockpit-generator
to start the generator. -
cockpit
to start all backend components (WSGI, manager, generator) managed by on process.
You can create a .env
to set your own environment variables. For example you could change the Port of the backend. You can have a look at the .env.example
. To see the default values have a look at hyrisecockpit.settings.py
You can install a python package via pipenv install
. Let's say you want to install psycopg2
. Simply run:
pipenv install psycopg2
After that you need to rebuild the requirements files:
pipenv run pipenv_to_requirements -o requirements.txt -f \
&& pipenv run pipenv_to_requirements -d requirements-dev.txt -f
If you want to install a package for development, let's say HalloWorld
please run:
pipenv install --dev HalloWorld
After that, you need to rebuild the requirements files.
If you want to install a hook, please set a fixed version. For example, if you want to install mypy
please run:
pipenv install --dev mypy==0.782
After that, you need to rebuild the requirements files.
If a package was installed by another PR and this PR is now merged, please make sure to update your packages. For that please run:
pipenv sync --dev
If you are switching to a PR where new packages were installed (for example they are not installed in dev and you switch to branch blabla) you need to run pipenv sync --dev
every time you switch to blabla or back to dev
If you want to run the pre-commit hooks manually without commiting, simply run:
pipenv run pre-commit
The hooks will run on all files that you added via git add
.
This will trigger all configured pre-commit hooks, most notably:
- Python code formatter
black
. Blackened code looks the same regardless of the project you're reading. Formatting becomes transparent after a while and you can focus on the content instead. - Python utility
flake8
, with pluginspep8-naming
andflake8-bugbear
. - Python utility
bandit
, a tool designed to find common security issues in Python code.
If some hooks fail, you will not be able to commit.
You may bypass this by using the git commit --no-verify
, but it's a good practice to avoid bypassing it.
Instead, add the edits made by e.g. black
to the staging area, and commit with the pre-commit hooks passing.
Some hooks, however, require you to change files manually, e.g. flake8
warning you of an unused variable.
You can run a single hook by running:
pipenv run pre-commit hook-id
The id of the hook can be found in the .pre-commit-config.yaml
file.
You can run all the pre-commit hooks on all files by running:
pipenv run pre-commit run --all-files
You can run all tests with:
pipenv run pytest
For a detailed explanation of how to run system tests please have a look at https://github.com/hyrise/Cockpit/wiki/System-Tests .
To start the server for development with hot-reloads, run:
cd hyrisecockpit/frontend && npm run serve
To automatically lint all files, run:
npm run lint
The frontend uses Cypress (https://www.cypress.io/) for UI/E2E-Testing. To start all tests with UI, run:
npm run test:e2e
To disable UI and execute all tests in headless mode, run: npm run test:e2e:headless
All of the tests are using a backend stub with mocked responses. This backend stub can also be used for development purposes by mocking all network requests in a local node server. To start this test server, execute the following steps:
cd Cockpit/hyrisecockpit/frontend/devServer
npm install
npm start
The server runs at http://127.0.0.1:3000/
per default. To connect to this server in your frontend app, replace the backendUrl in the top level config.ts
. To run all tests against this server execute npm run test:e2e:stubless
or test:e2e:headless:stubless
. If you have some problems try to run npm run start:dev:ci & npm run test:e2e:headless:stubless
to execute all tests, or npm run start:dev:ci & npm run test:e2e:spec:headless "tests/e2e/specs/workloadGeneration/workloadGeneration.spec.ts"
to execute a specific test (in this case workloadGeneration.spec.ts).
If you change something in the setup.py
for example add a new console script please run:
pipenv --rm
pipenv --three install
pipenv sync --dev