DNAnexus Platform API bindings for Python
Actively maintained. Last release 6 days ago, commits in 20 of the last 26 weeks. A safe choice.
pip install dxpydxpy: DNAnexus Python API
Building
From the dx-toolkit root directory:
python3 -m pip install -e src/python
Debugging
Set the _DX_DEBUG environment variable to a positive integer before
running a dxpy-based program (such as dx) to display the input and
output of each API call. Supported values are 1, 2, and 3 with
increasing numbers producing successively more verbose output.
Example:
$ _DX_DEBUG=1 dx ls
Debugging inside the IDE (PyCharm)
To be able to debug dx-toolkit (dx commands) directly in the IDE, 'Run/Debug Configurations' needs to be changed.
- Go to Run → Edit Configurations...
- Add New Configuration (Python)
- Change script to module (dxpy.scripts.dx)
- To Script parameters field write dx command you want to run (eg 'ls' runs 'dx ls')
- Apply and OK (now it is possible to start debugging via main() function in dx.py)
Python coding style
- Conform to PEP-8.
- Relax the line length requirement to 120 characters per line, where you judge readability not to be compromised.
- Relax other PEP-8 requirements at your discretion if it simplifies code or is needed to follow conventions established elsewhere at DNAnexus.
- Document your code in a format usable by Sphinx Autodoc.
- Run
pylint -Eon your code before checking it in. - Do not introduce module import-time side effects.
-
Do not add module-level attributes into the API unless you are absolutely certain they will remain constants. For example, do not declare an attribute
dxpy.foo(dxpy._foois OK), or any other non-private variable in the global scope of any module. This is because unless the value is a constant, it may need to be updated by an initialization method, which may need to run lazily to avoid side effects at module load time. Instead, use accessor methods that can perform the updates at call time:_foo = None def get_foo(): initialize() return _foo
-