Skip to content

Commit db2eb85

Browse files
authored
Fix directory structure in the best practices guide on parametrizations. (#208)
1 parent 42da034 commit db2eb85

File tree

2 files changed

+41
-27
lines changed

2 files changed

+41
-27
lines changed

docs/source/changes.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ all releases are available on `PyPI <https://pypi.org/project/pytask>`_ and
77
`Anaconda.org <https://anaconda.org/conda-forge/pytask>`_.
88

99

10-
0.1.6 - 2022-xx-xx
10+
0.1.6 - 2022-01-27
1111
------------------
1212

1313
- :gh:`191` adds a guide on how to profile pytask to the developer's guide.
@@ -23,6 +23,7 @@ all releases are available on `PyPI <https://pypi.org/project/pytask>`_ and
2323
- :gh:`201` adds tests for ``_pytask.mark_utils``.
2424
- :gh:`204` removes internal traceback frames from exceptions raised somewhere in
2525
pytask.
26+
- :gh:`208` fixes the best practices guide for parametrizations.
2627

2728

2829
0.1.5 - 2022-01-10

docs/source/how_to_guides/bp_parametrizations.rst

+39-26
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,50 @@ First, let us take a look at the folder and file structure of such a project.
3434

3535
.. code-block::
3636
37-
src
38-
│ config.py
37+
my_project
38+
├───pytask.ini or tox.ini or setup.cfg
3939
40-
├───data
41-
│ data_0.csv
42-
│ data_1.csv
43-
│ data_2.csv
44-
│ data_3.csv
40+
├───src
41+
│ └───my_project
42+
│ ├────config.py
43+
│ │
44+
│ ├───data
45+
│ │ ├────data_0.csv
46+
│ │ ├────data_1.csv
47+
│ │ ├────data_2.csv
48+
│ │ └────data_3.csv
49+
│ │
50+
│ ├───data_preparation
51+
│ │ ├────data_preparation_config.py
52+
│ │ └────task_prepare_data.py
53+
│ │
54+
│ └───estimation
55+
│ ├────estimation_config.py
56+
│ └────task_estimate_models.py
4557
46-
├───data_preparation
47-
│ data_preparation_config.py
48-
│ task_prepare_data.py
4958
50-
└───estimation
51-
estimation_config.py
52-
task_estimate_models.py
59+
├───setup.py
60+
61+
├───.pytask.sqlite3
62+
63+
└───bld
64+
65+
5366
5467
The folder structure, the general ``config.py`` which holds ``SRC`` and ``BLD`` and the
5568
tasks follow the same structure which is advocated for throughout the tutorials.
5669

57-
What is new are the local configuration files in each of the subfolders of ``src`` which
58-
contain objects which are shared across tasks. For example,
70+
What is new are the local configuration files in each of the subfolders of
71+
``my_project`` which contain objects which are shared across tasks. For example,
5972
``data_preparation_config.py`` holds the paths to the processed data and the names of
6073
the data sets.
6174

6275
.. code-block:: python
6376
6477
# Content of data_preparation_config.py
6578
66-
from src.config import BLD
67-
from src.config import SRC
79+
from my_project.config import BLD
80+
from my_project.config import SRC
6881
6982
7083
DATA = ["data_0", "data_1", "data_2", "data_3"]
@@ -87,9 +100,9 @@ parametrization.
87100
88101
import pytask
89102
90-
from src.data_preparation.data_preparation_config import DATA
91-
from src.data_preparation.data_preparation_config import path_to_input_data
92-
from src.data_preparation.data_preparation_config import path_to_processed_data
103+
from my_project.data_preparation.data_preparation_config import DATA
104+
from my_project.data_preparation.data_preparation_config import path_to_input_data
105+
from my_project.data_preparation.data_preparation_config import path_to_processed_data
93106
94107
95108
def _create_parametrization(data):
@@ -121,7 +134,7 @@ an explicit id.
121134
.. code-block::
122135
123136
# With id
124-
.../src/data_preparation/task_prepare_data.py::task_prepare_data[data_0]
137+
.../my_project/data_preparation/task_prepare_data.py::task_prepare_data[data_0]
125138
126139
Next, we move to the estimation to see how we can build another parametrization upon the
127140
previous one.
@@ -130,8 +143,8 @@ previous one.
130143
131144
# Content of estimation_config.py
132145
133-
from src.config import BLD
134-
from src.data_preparation.data_preparation_config import DATA
146+
from my_project.config import BLD
147+
from my_project.data_preparation.data_preparation_config import DATA
135148
136149
137150
_MODELS = ["linear_probability", "logistic_model", "decision_tree"]
@@ -164,9 +177,9 @@ And, here is the task file.
164177
165178
import pytask
166179
167-
from src.data_preparation.data_preparation_config import path_to_processed_data
168-
from src.data_preparation.estimation_config import ESTIMATIONS
169-
from src.data_preparation.estimation_config import path_to_estimation_result
180+
from my_project.data_preparation.data_preparation_config import path_to_processed_data
181+
from my_project.data_preparation.estimation_config import ESTIMATIONS
182+
from my_project.data_preparation.estimation_config import path_to_estimation_result
170183
171184
172185
def _create_parametrization(estimations):

0 commit comments

Comments
 (0)