Debian Codegraph @

doc/tutorials/organizing_your_repository.rst

raw
1 .. _organizing-your-repository:
2
3 Organizing your repository
4 ==========================
5
6 This document covers suggestions for organizing your repository to align with how pyqi and projects that use pyqi are organized. Following these guidelines is not a requirement, but may simplify using pyqi in your project. Version 1.1.3 of the `biom-format <http://www.biom-format.org>`_ project was the first project to use pyqi for its commands and interfaces, so the structure of that repository is used as an example here.
7
8
9 Structure of the biom-format project
10 ------------------------------------
11
12 This directory tree (created with the unix ``tree`` command) illustrates the structure of the biom-format repository (some files that are not relevant to this discussion have been omitted to keep this as simple as possible). Annotations have been added following ``##`` to reference specific directories.
13
14 ::
15
16 biom-format/
17 ├── ChangeLog
18 ├── COPYING
19 ├── doc
20 ├── examples
21 ├── images
22 ├── INSTALL
23 ├── python-code
24 │   ├── biom ## Library code directory
25 │   │   ├── biomdb.py
26 │   │   ├── commands ## derived Command classes
27 │   │   │   ├── __init__.py
28 │   │   │   ├── installation_informer.py
29 │   │   │   ├── metadata_adder.py
30 │   │   │   ├── table_subsetter.py
31 │   │   │   ├── table_summarizer.py
32 │   │   │   └── table_validator.py
33 │   │   ├── csmat.py
34 │   │   ├── dbdata.py
35 │   │   ├── exception.py
36 │   │   ├── __init__.py
37 │   │   ├── interfaces ## per-interface-type directories
38 │   │   │   ├── __init__.py
39 │   │   │   └── optparse ## derived OptparseInterface classes
40 │   │   │   ├── config
41 │   │   │   │   ├── add_metadata.py
42 │   │   │   │   ├── __init__.py
43 │   │   │   │   ├── show_install_info.py
44 │   │   │   │   ├── subset_table.py
45 │   │   │   │   ├── summarize_table.py
46 │   │   │   │   └── validate_table.py
47 │   │   │   ├── __init__.py
48 │   │   │   ├── input_handler.py ## general purpose OptparseInterface input handler functions
49 │   │   │   └── output_handler.py ## general purpose OptparseInterface output handler functions
50 │   │   ├── parse.py
51 │   │   ├── sparsedict.py
52 │   │   ├── sparsemat.py
53 │   │   ├── table.py
54 │   │   ├── unit_test.py
55 │   │   └── util.py
56 │   ├── support-code
57 │   └── tests ## Test code directory
58 │   ├── bench
59 │   ├── __init__.py
60 │   ├── test_biomdb.py
61 │   ├── test_commands # unit tests of the derived Command classes
62 │   │   ├── __init__.py
63 │   │   ├── test_installation_informer.py
64 │   │   ├── test_metadata_adder.py
65 │   │   ├── test_table_subsetter.py
66 │   │   ├── test_table_summarizer.py
67 │   │   └── test_table_validator.py
68 │   ├── test_csmat.py
69 │   ├── test_dbdata.py
70 │   ├── test_interfaces # unit tests of input and output handlers
71 │   │   ├── __init__.py
72 │   │   ├── test_optparse
73 │   │   │   ├── __init__.py
74 │   │   │   ├── test_input_handler.py ## tests of OptparseInterface input handler functions
75 │   │   │   └── test_output_handler.py ## tests of OptparseInterface output handler functions
76 │   ├── test_parse.py
77 │   ├── test_sparsedict.py
78 │   ├── test_sparsemat.py
79 │   ├── test_table.py
80 │   ├── test_unit_test.py
81 │   └── test_util.py
82 ├── R-code
83 ├── README.md
84 ├── scripts
85 │   └── biom ## biom command driver
86 ├── setup.py
87 └── support_files
88
89 Discussion of the biom-format directory structure
90 -------------------------------------------------
91
92 Under the ``biom`` *library code directory*, there are two directories that house pyqi-related code. The first is ``commands``, which contains derivations of the ``Command`` class (see :ref:`defining-new-commands` for discussion of these files). All of the ``biom-format`` commands are therefore defined in this directory. The second is ``interfaces``, which contains all of the derivations of the pyqi ``Interface`` class, and which are nested based on interface type. Currently ``biom-format`` only implements ``OptparseInterface`` classes, so there is only an ``optparse`` directory, but by nesting these on an per-interface-type basis we avoid name conflicts if multiple interfaces types were defined.
93
94 Under the ``biom/interfaces/optparse`` directory, there is a ``config`` directory which contains all of the config files (see :ref:`defining-new-interfaces` for discussion of these files). There are also top-level ``input_handler.py`` and ``output_handler.py`` files. These files contain general purpose input and output handlers that may be used in multiple ``OptparseInterfaces``. Since input and output handlers are interface specific, it makes sense for these files to be contained under the ``biom/interfaces/optparse`` directory.
95
96 Under the ``tests`` directory there are subdirectories for ``test_commands`` and ``test_interfaces``. The ``test_commands`` directory should contain a file corresponding to each file in the ``biom/commands`` directory, and should provide extensive unit testing of each of your commands. The ``test_interfaces`` directory is more minimal as typically there is not any functionality in the interfaces (the files are just providing configuration details). The exception is the input and output handlers, so there are test files corresponding to the files where those are defined. Note that the nesting of all test files matches the nesting in the library code directory.
97
98 Finally, under the ``scripts`` directory there is a single executable, ``biom``, which is the ``OptparseInterface`` command driver. This is a simple shell script that allows users to access the ``OptparseInterfaces`` defined in the ``biom-format`` project. Defining this script for your project is covered in :ref:`defining-your-command-driver`.
99