-
Notifications
You must be signed in to change notification settings - Fork 54
Tips for Python
We are using Flask web development framework. If you are not familiar with Flask, you can peruse a good tutorial such as Miguel Grinberg's The Flask Mega-Tuturial.
We are using pytest framework for unit testing. You may want to peruse its getting started tutorial.
All pytest-related fixtures and helpers are centralised in pytest-reana package.
For persistence, we are using SQLAlchemy. You may want to peruse its tutorial.
For database schema and model upgrades, we are using Alembic. You may want to peruse its tutorial.
For creating command-line executables, parsing command-line arguments etc, we are using click.
We are using Black code formatter. The code formatting is checked during CI build
$ pip install --upgrade black
We are not imposing a particular import order during CI build process, but we try to rely on isort rules gently applied locally.
This means to keep several import sections (separated by empty line) in the following order:
- Python built-in modules
- External dependency modules
- Local imports
Example:
from __future__ import absolute_import, print_function
import logging
import os
from reana_commons.config import REANA_LOG_FORMAT, REANA_LOG_LEVEL
from reana_commons.serial import serial_load
from reana_commons.workflow_engine import create_workflow_engine_command
from .config import CACHE_ENABLED
from .utils import (
build_job_spec,
check_cache,
copy_workspace_from_cache,
copy_workspace_to_cache,
get_targeted_workflow_steps,
poll_job_status,
publish_cache_copy,
publish_job_submission,
publish_job_success,
publish_workflow_failure,
publish_workflow_start,
)
We are using Flake8 code checker. The Flake8 compliance is checked during CI build.
In order for Flake8 to play nicely with Black, a special configuration is used:
[flake8]
max-line-length = 89
ignore = E203, E231, E266, E501, W503, F403, F401
max-complexity = 18
select = B,C,E,F,W,T4,B9
The REANA components usually contain .flake8
configuration files that are
ready to be used. Please respect them and don't modify them individually.
REANA reproducible analysis platform
blog.reana.io | docs.reana.io | forum.reana.io | www.reana.io |
@gitter | @mattermost | @twitter
Introduction
Getting started
- Setting up your system
- Cloning sources
- Using production-like development mode
- Using live-code-reload and debug mode
Issue lifecycle
Understanding code base
Technology tips and tricks
- Tips for Docker
- Tips for Git
- Tips for GitLab
- Tips for Keycloak
- Tips for Kind
- Tips for Kubernetes
- Tips for OpenAPI
- Tips for PostgreSQL
- Tips for Python
- Tips for RabbitMQ
- Tips for SQLAlchemy