-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathpkg-management.qmd
More file actions
391 lines (264 loc) · 8.49 KB
/
Copy pathpkg-management.qmd
File metadata and controls
391 lines (264 loc) · 8.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# Project management {#sec-pkg-management}
::: callout-tip
## Objective
Learn Git-centric workflows for managing clinical analysis projects.
Understand agile development practices and validation strategies for regulatory compliance.
:::
## Git-centric workflow
Clinical analysis projects require rigorous tracking and collaboration.
A Git-centric workflow provides the foundation for reproducible, auditable work.
**Core principle:**
All project assets live in version control.
Work is tracked through issues, pull requests, and project boards.
This applies whether you use:
- GitHub Enterprise
- GitLab Self-Managed/Dedicated
- Bitbucket Data Center
- Azure DevOps
The specific platform matters less than the workflow discipline.
## Plain text workflow
Favor plain text formats for all project artifacts:
**Use:**
- `.qmd` files for analysis scripts (not Jupyter notebooks for final deliverables)
- `.md` files for documentation
- `.toml` files for configuration
- `.txt` files for submission packages
**Avoid:**
- `.xlsx` files for tracking (no audit trail, merge conflicts)
- Binary formats when text alternatives exist
- Proprietary formats that require special tools
::: callout-note
Plain text enables:
- Clear diff views in pull requests
- Meaningful merge conflict resolution
- Searchable code history
- Command-line friendly workflows
:::
## Project tracking
Use properly labeled issues and pull requests to drive work.
Follow [Tidyteam code review principles](https://code-review.tidyverse.org/)
for detailed operational advices.
### Issues for requirements
Create issues to capture:
- Individual TLF specifications
- Bug reports
- Feature requests
- Validation tasks
Example issue template:
```markdown
**Title**: Implement Table 14.1.1 - Disposition of Patients
**Description**:
Create disposition table following ICH E3 guidelines
**Deliverables**:
- [ ] Quarto document: analysis/tlf-01-disposition.qmd
- [ ] Output table: output/tlf-disposition.rtf
- [ ] Unit tests: tests/test_disposition.py
**Validation**: Independent review required
```
### Pull requests for review
**ALL** code changes must go through pull requests before getting into `main`:
- Developer creates feature branch
- Implements changes
- Opens pull request for review
- Reviewer validates code and outputs
- Changes merged after approval
This creates an audit trail of who did what and when.
### Project boards
Use Kanban-style project boards to visualize work:
**Columns:**
- Backlog: Planned work
- In Progress: Active development
- Review: Awaiting validation
- Done: Completed and validated
**Example board:**
| Backlog | In Progress | Review | Done |
|---------|-------------|--------|------|
| Table 14.3.5 | Table 14.1.1 | Table 14.2.1 | Table 14.1.2 |
| Figure 14.4.1 | | Table 14.3.1 | Table 14.2.2 |
This makes project status transparent to all stakeholders.
::: aside
GitHub Projects, GitLab Boards, and Jira all support this workflow.
Choose based on your organization's infrastructure.
:::
## Development lifecycle
Clinical analysis projects follow a structured development lifecycle similar to software development.
### Planning
Define scope and requirements:
- List all TLFs from Statistical Analysis Plan (SAP)
- Create mock tables/shells
- Assign validation levels (independent review vs double programming)
- Set up validation tracking
Create a validation tracker (plain text format):
```markdown
| TLF | Type | Developer | Dev Status | Reviewer | Review Status |
|-----|------|-----------|------------|----------|---------------|
| tlf-01-disposition | Table | Alice | Complete | Bob | In Progress |
| tlf-02-population | Table | Charlie | In Progress | Diana | Pending |
```
::: callout-important
Lock down the Python version and package repository snapshot during planning.
Changing these mid-project breaks reproducibility.
:::
### Development
Team members implement assigned TLFs:
**1. Create feature branch:**
```bash
git checkout -b feature/tlf-01-disposition
```
**2. Implement analysis:**
- Write Quarto document in `analysis/`
- Create helper functions in `src/` if needed
- Generate output in `output/`
**3. Self-test:**
- Verify against mock table
- Check calculations manually
- Run automated tests
**4. Commit and push:**
```bash
git add analysis/tlf-01-disposition.qmd
git commit -m "Implement disposition table (Table 14.1.1)"
git push origin feature/tlf-01-disposition
```
**5. Open pull request:**
Request review from assigned validator.
### Validation
Independent reviewers verify deliverables:
**For tables:**
- Compare output against specifications
- Verify calculations independently
- Check formatting requirements
- Review code for errors
**For analysis functions:**
- Write unit tests in `tests/`
- Verify edge cases
- Check type annotations
- Review docstrings
**Validation testing example:**
```python
# tests/test_disposition.py
import polars as pl
from demo001.disposition import create_disposition_table
def test_disposition_counts():
"""Verify disposition table calculations."""
# Load test data
df = pl.read_parquet("tests/data/adsl_subset.parquet")
# Generate table
result = create_disposition_table(df)
# Verify counts
assert result["Screened"][0] == 254
assert result["Randomized"][0] == 254
assert result["Completed"][0] == 238
```
Run tests with pytest:
```bash
uv run pytest
```
### Delivery
Project lead ensures completion:
**1. Run compliance checks:**
```bash
uv run ruff check .
uv run mypy src/
uv run pytest --cov=demo001
```
**2. Generate all outputs in batch:**
```bash
quarto render
```
**3. Review validation tracker:**
Ensure all TLFs have completed validation.
**4. Prepare submission package:**
Pack for eCTD (covered in @sec-submission-package).
## Agile practices
Clinical trials benefit from agile project management:
**Iterative development:**
- Work in 2-week sprints
- Deliver subset of TLFs each sprint
- Get stakeholder feedback early
**Continuous integration:**
- Automated testing on every push
- Catch errors before review
- Maintain code quality
**Regular retrospectives:**
- What went well?
- What needs improvement?
- Adjust process accordingly
::: callout-note
Agile doesn't mean uncontrolled.
The validation requirements remain the same.
Agile provides faster feedback loops within those constraints.
:::
## Automation with CI/CD
Automate repetitive tasks using continuous integration:
**GitHub Actions example:**
```yaml
name: Validation
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
- run: uv sync
- run: uv run pytest tests/
- run: uv run ruff check .
- run: uv run mypy src/
```
This runs tests automatically on every pull request.
**Benefits:**
- Catch errors before manual review
- Ensure consistent code quality
- Reduce reviewer burden
- Document test results
::: aside
CI/CD is optional but highly recommended for projects with multiple developers.
:::
## Collaboration best practices
**Work as a team:**
- Take project management training
- Understand your role in the lifecycle
- Communicate blockers early
**Design clean architecture:**
- Separate business logic from data processing
- Write reusable components in `src/`
- Keep analysis scripts in `analysis/` focused
**Set capability boundaries:**
- Know what your team can deliver
- Avoid complex integrations (e.g., mixing R and Python in same package)
- Prefer simple, robust solutions
**Contribute to community:**
- Share reusable components internally
- Open source when possible
- Learn from others' approaches
## Version control discipline
**Branch strategy:**
- `main`: Stable, validated code
- `feature/*`: Development branches
- `hotfix/*`: Emergency fixes
**Commit messages:**
Write clear, descriptive commits:
```bash
# Good
git commit -m "Add ANCOVA analysis for primary endpoint (Table 14.2.1)"
# Bad
git commit -m "Update code"
```
**Never commit:**
- Sensitive data
- Large binary files
- Generated outputs (use `.gitignore`)
- Temporary files
**Always commit:**
- Source code (`.py`, `.qmd`)
- Configuration (`pyproject.toml`, `_quarto.yml`)
- Documentation (`README.md`)
- Tests (`tests/*.py`)
## What's next
You've learned Git-centric project management workflows.
The next chapter covers the detailed package structure:
- Directory layout for analysis packages
- Organizing code and content
- Integrating Quarto with Python packages
- Essential configuration files
These practices ensure consistent, reproducible, collaborative clinical analysis projects.