Skip to content

Commit 4a5515d

Browse files
committed
differences for PR #447
1 parent 98d38d2 commit 4a5515d

12 files changed

+54
-129
lines changed

12-virtual-environments.md

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -483,67 +483,6 @@ six 1.16.0
483483
To uninstall a package installed in the virtual environment do: `python3 -m pip uninstall <package-name>`.
484484
You can also supply a list of packages to uninstall at the same time.
485485

486-
### Installing Our Local Project as a Package Using `pip`
487-
488-
Often when working on a Python project, the project itself will be a Python package (like `numpy` or `matplotlib` above) or at the very least it might be useful to treat it like a package.
489-
Said another way, it is usually the case we want a convenient way to call the Python code we are writing from another location, and making this code accessible as a package is the best way to do this.
490-
We will save the details of Python packaging for [a future episode](43-software-release.md), and for the meantime we can use the minimal package setup that our project already comes with, which is contained in the `pyproject.toml` file.
491-
Once again, we can use `pip` to install our local package:
492-
493-
```bash
494-
python3 -m pip install --editable .
495-
```
496-
497-
::::::::::::::::::::::::::::::::::::::::: spoiler
498-
499-
### This command fails for me
500-
501-
If your `pip` installation is older than version 21.3, then this command will probably fail for you.
502-
This is because these older versions of `pip` do not support `pyproject.toml` as the package metadata.
503-
Given these versions of `pip` are now over 4 years old, we strongly recommend that you update `pip` if you can:
504-
505-
```bash
506-
python3 -m pip install --upgrade pip
507-
```
508-
509-
:::::::::::::::::::::::::::::::::::::::::
510-
511-
This is similar syntax to above, with two important differences:
512-
513-
1. The `--editable` or `-e` flag indicates that the package we are specifying should be an "editable" install.
514-
An "editable" install is one that allows the package in our environment to change dynamically based on source code locally.
515-
This is very convenient when we are developing the package because we can instantly see changes when we call the code from within our virtual environment, rather than having to install the local package again to get the updates.
516-
2. The argument `'.'` indicates that the package we want to install is located in the current directory.
517-
The `pyproject.toml` file located in this directory then handles the rest.
518-
519-
520-
521-
If we reissue the `pip list` command we should now see our local package with the name `python-intermediate-inflammation` in the output:
522-
523-
```output
524-
Package Version Editable project location
525-
-------------------------------- ----------- ----------------------------------------------------------------------------------------------
526-
contourpy 1.3.1
527-
cycler 0.12.1
528-
exceptiongroup 1.2.2
529-
fonttools 4.56.0
530-
iniconfig 2.0.0
531-
kiwisolver 1.4.8
532-
matplotlib 3.10.0
533-
numpy 2.2.3
534-
packaging 24.2
535-
pillow 11.1.0
536-
pip 22.0.2
537-
pluggy 1.5.0
538-
pyparsing 3.2.1
539-
pytest 8.3.4
540-
python-dateutil 2.9.0.post0
541-
python-intermediate-inflammation 0.0.0 /path/to/your/project/directory/python-intermediate-inflammation
542-
setuptools 59.6.0
543-
six 1.17.0
544-
tomli 2.2.1
545-
```
546-
547486
### Exporting/Importing Virtual Environments Using `pip`
548487

549488
You are collaborating on a project with a team so, naturally,
@@ -552,11 +491,12 @@ so they can easily 'clone' your software project with all of its dependencies
552491
and everyone can replicate equivalent virtual environments on their machines.
553492
`pip` has a handy way of exporting, saving and sharing virtual environments.
554493

555-
To export your active environment use the `python3 -m pip freeze --exclude-editable` command to produce a list of packages installed in the virtual environment.
494+
To export your active environment -
495+
use `python3 -m pip freeze` command to produce a list of packages installed in the virtual environment.
556496
A common convention is to put this list in a `requirements.txt` file:
557497

558498
```bash
559-
(venv) $ python3 -m pip freeze --exclude-editable > requirements.txt
499+
(venv) $ python3 -m pip freeze > requirements.txt
560500
(venv) $ cat requirements.txt
561501
```
562502

@@ -578,7 +518,6 @@ The first of the above commands will create a `requirements.txt` file in your cu
578518
Yours may look a little different,
579519
depending on the version of the packages you have installed,
580520
as well as any differences in the packages that they themselves use.
581-
Also, we need to use the `--exclude-editable` command so that our local package is not included in the output, otherwise pip will try to pull from a specific commit at the time we made the editable install, which is not what we want.
582521

583522
The `requirements.txt` file can then be committed to a version control system
584523
(we will see how to do this using Git in one of the following episodes)
@@ -587,10 +526,10 @@ They can then replicate your environment
587526
and install all the necessary packages from the project root as follows:
588527

589528
```bash
590-
(venv) $ python3 -m pip install -r requirements.txt --editable .
529+
(venv) $ python3 -m pip install -r requirements.txt
591530
```
592531

593-
As your project grows you may need to update your environment for a variety of reasons.
532+
As your project grows - you may need to update your environment for a variety of reasons.
594533
For example, one of your project's dependencies has just released a new version
595534
(dependency version number update),
596535
you need an additional package for data analysis (adding a new dependency)
@@ -665,7 +604,7 @@ to customize the command line.
665604
- Use `venv` to create and manage Python virtual environments.
666605
- Use `pip` to install and manage Python external (third-party) libraries.
667606
- `pip` allows you to declare all dependencies for a project in a separate file (by convention called `requirements.txt`) which can be shared with collaborators/users and used to replicate a virtual environment.
668-
- Use `python3 -m pip freeze --exclude-editable > requirements.txt` to take snapshot of your project's dependencies.
607+
- Use `python3 -m pip freeze > requirements.txt` to take snapshot of your project's dependencies.
669608
- Use `python3 -m pip install -r requirements.txt` to replicate someone else's virtual environment on your machine from the `requirements.txt` file.
670609

671610
::::::::::::::::::::::::::::::::::::::::::::::::::

13-ides.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ you may remember that we can get the list of packages in the current virtual env
203203
using `pip`:
204204

205205
```bash
206-
(venv) $ python3 -m pip list --exclude-editable
206+
(venv) $ python3 -m pip list
207207
```
208208

209209
```output
@@ -231,7 +231,7 @@ if we want to see only the list of packages that we installed,
231231
we can use the `python3 -m pip freeze` command instead:
232232

233233
```bash
234-
(venv) $ python3 -m pip freeze --exclude-editable
234+
(venv) $ python3 -m pip freeze
235235
```
236236

237237
```output
@@ -250,13 +250,13 @@ six==1.16.0
250250

251251
We see the `pip` package in `python3 -m pip list` but not in `python3 -m pip freeze`
252252
as we did not install it using `pip`.
253-
Remember that we use `python3 -m pip freeze --exclude-editable` to update our `requirements.txt` file,
253+
Remember that we use `python3 -m pip freeze` to update our `requirements.txt` file,
254254
to keep a list of the packages our virtual environment includes.
255255
Python will not do this automatically;
256256
we have to manually update the file when our requirements change using:
257257

258258
```bash
259-
python3 -m pip freeze --exclude-editable > requirements.txt
259+
python3 -m pip freeze > requirements.txt
260260
```
261261

262262
If we want, we can also see the list of packages directly in the following subdirectory of `venv`:
@@ -399,7 +399,7 @@ six==1.16.0
399399
`pytest` is missing from `requirements.txt`. To add it, we need to update the file by repeating the command:
400400

401401
```bash
402-
(venv) $ python3 -m pip freeze --exclude-editable > requirements.txt
402+
(venv) $ python3 -m pip freeze > requirements.txt
403403
```
404404

405405
`pytest` is now present in `requirements.txt`:

16-verifying-code-style-linters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ $ python3 -m pip install pylint
4444
We should also update our `requirements.txt` with this new addition:
4545

4646
```bash
47-
$ python3 -m pip freeze --exclude-editable > requirements.txt
47+
$ python3 -m pip freeze > requirements.txt
4848
```
4949

5050
Pylint is a command-line tool that can help our code in many ways:

21-automatically-testing-software.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ Since we have installed `pytest` to our environment,
614614
we should also regenerate our `requirements.txt`:
615615

616616
```bash
617-
$ python3 -m pip freeze --exclude-editable > requirements.txt
617+
$ python3 -m pip freeze > requirements.txt
618618
```
619619

620620
Finally, let us commit our new `test_models.py` file,

22-scaling-up-unit-testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Again, we should also update our `requirements.txt` file with our latest package
213213
which now also includes `pytest-cov`, and commit it:
214214

215215
```bash
216-
$ python3 -m pip freeze --exclude-editable > requirements.txt
216+
$ python3 -m pip freeze > requirements.txt
217217
$ cat requirements.txt
218218
```
219219

23-continuous-integration-automated-testing.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ Let us say we want to add more detail to our list of initial ascenders:
128128
...
129129
first_scaled_by:
130130
- name: Hans Meyer
131-
date_of_birth: 22-03-1858
131+
date_of_birth: 1858-03-22
132132
nationality: German
133133
- name: Ludwig Purtscheller
134-
date_of_birth: 22-03-1858
134+
date_of_birth: 1858-03-22
135135
nationality: Austrian
136136
```
137137

@@ -200,7 +200,7 @@ jobs:
200200
- name: Install Python dependencies
201201
run: |
202202
python3 -m pip install --upgrade pip
203-
python3 -m pip install -r requirements.txt .
203+
python3 -m pip install -r requirements.txt
204204
205205
- name: Test with PyTest
206206
run: |
@@ -244,7 +244,7 @@ Each of these steps are:
244244
In order to locally install our `inflammation` package
245245
it is good practice to upgrade the version of pip that is present first,
246246
then we use pip to install our package dependencies.
247-
Notice that it is fine to omit the `--editable` flag in this case because the source code will be static and therefore we don't need this to be an "editable" install like when we are developing locally.
247+
Once installed, we can use `python3 -m pip install -e .` as before to install our own package.
248248
We use `run` here to run theses commands in the CI shell environment
249249
- **Test with PyTest:** lastly, we run `python3 -m pytest`,
250250
with the same arguments we used manually before
@@ -383,10 +383,10 @@ jobs:
383383
- name: Install Python dependencies
384384
run: |
385385
python3 -m pip install --upgrade pip
386-
python3 -m pip install -r requirements.txt .
386+
python3 -m pip install -r requirements.txt
387387
- name: Test with PyTest
388388
run: |
389-
python3 -m pytest --cov=inflammation.models tests/test_models.py
389+
python3 -m pytest --cov=catchment.models tests/test_models.py
390390
```
391391

392392
The `{{ }}` are used

33-code-decoupling-abstractions.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -390,25 +390,17 @@ data sources with no extra work.
390390

391391
Create another class that supports loading patient data from JSON files, with the
392392
appropriate `load_inflammation_data()` method.
393-
Here is an example function that you can add to your `models.py` file to load observations from a JSON file:
394-
```python
395-
def load_json(filename):
396-
"""Load a numpy array from a JSON document.
397-
398-
Expected format:
399-
[
400-
{
401-
"observations": [0, 1]
402-
},
403-
{
404-
"observations": [0, 2]
405-
}
406-
]
407-
:param filename: Filename of CSV to load
408-
"""
409-
with open(filename, 'r', encoding='utf-8') as file:
410-
data_as_json = json.load(file)
411-
return [np.array(entry['observations']) for entry in data_as_json]
393+
There is a function in `models.py` that loads from JSON in the following format:
394+
395+
```json
396+
[
397+
{
398+
"observations": [0, 1]
399+
},
400+
{
401+
"observations": [0, 2]
402+
}
403+
]
412404
```
413405

414406
Finally, at run-time, construct an appropriate data source instance based on the file extension.

41-code-review.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,19 @@ There is doing to be an exercise next for you to practice it.
321321
repository as a collaborator.
322322
You will have to do the same for the collaborator doing the review on your repository.
323323

324-
**Note:** *You do not have to be a collaborator on a public repository to do code reviews
324+
::::::::::::::::::::::::::::::::::::::::: callout
325+
326+
## Code Review from External Contributors
327+
328+
You do not have to be a collaborator on a public repository to do code reviews
325329
so this step is not strictly necessary.
326330
We are still asking you to do it now as we will get you working in teams
327-
for the rest of the course so it may make sense to start setting up your collaborators now - as
328-
shown in the screenshot below.*
331+
for the rest of the course so it may make sense to start setting up your collaborators now.
329332

330333
![](fig/github-add-collaborator.png){alt='Adding a collaborator in GitHub' .image-with-shadow width="900px"}
331334

335+
::::::::::::::::::::::::::::::::::::::::::::::::::
336+
332337
2. Locate up the pull request from the GitHub's `Pull Requests` tab on the home page
333338
of your fellow learner's software repository, then head to the `Files changed` tab
334339
on the pull request.

43-software-release.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Poetry can also handle virtual environments for us,
8282
so in order to behave similarly to how we used them previously,
8383
let us change the Poetry config to put them in the same directory as our project:
8484

85-
```bash
85+
```bash, bash
8686
$ poetry config virtualenvs.in-project true
8787
```
8888

@@ -111,17 +111,6 @@ although use your own contact details!*
111111
**NB: When you get to the questions about defining our dependencies,
112112
answer no, so we can do this separately later.**
113113

114-
::::::::::::::::::::::::::::::::::::::::: callout
115-
116-
## It's Not Interactive?
117-
118-
If you're using Git Bash for Windows, depending on your configuration, you may find after typing this command that you don't have an interactive set of questions displayed.
119-
Instead, you may find the `pyproject.toml` file is simply generated with a set of default values.
120-
121-
If this happens, you can edit the `pyproject.toml` file and change the values in this file, similarly to how we have in the output below.
122-
123-
:::::::::::::::::::::::::::::::::::::::::
124-
125114
```bash
126115
$ poetry init
127116
```

md5sum.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@
99
"episodes/00-setting-the-scene.md" "134311748519aaa07caa19a7989357ff" "site/built/00-setting-the-scene.md" "2024-12-06"
1010
"episodes/10-section1-intro.md" "5a9130373443cadeb19aa1a46dd3c1b2" "site/built/10-section1-intro.md" "2024-12-06"
1111
"episodes/11-software-project.md" "f5e403d2b25781407eaed7534dfff9ec" "site/built/11-software-project.md" "2024-12-06"
12-
"episodes/12-virtual-environments.md" "6f7c0e1d6693d17f43565f85498ea0b8" "site/built/12-virtual-environments.md" "2025-03-07"
13-
"episodes/13-ides.md" "5a1badf094a9022c001bdbdbf7ceedfa" "site/built/13-ides.md" "2025-03-07"
12+
"episodes/12-virtual-environments.md" "f49837c733584f7bca96cef405b2dcc0" "site/built/12-virtual-environments.md" "2025-04-01"
13+
"episodes/13-ides.md" "1ae19b798bc07c88f241ec792ff41ef3" "site/built/13-ides.md" "2025-04-01"
1414
"episodes/14-collaboration-using-git.md" "065fefef86c0202023975a04120da090" "site/built/14-collaboration-using-git.md" "2024-12-06"
1515
"episodes/15-coding-conventions.md" "930ee3f977bcde70f4919a8e11ba3e02" "site/built/15-coding-conventions.md" "2024-12-16"
16-
"episodes/16-verifying-code-style-linters.md" "0cb677e60bb505b78e523617f49f33de" "site/built/16-verifying-code-style-linters.md" "2025-03-07"
16+
"episodes/16-verifying-code-style-linters.md" "d790a49e61e0c28fc2eb153ec1a00d82" "site/built/16-verifying-code-style-linters.md" "2025-04-01"
1717
"episodes/17-section1-optional-exercises.md" "c7a9b304ba70d7d15ea5334fd211248b" "site/built/17-section1-optional-exercises.md" "2024-12-06"
1818
"episodes/20-section2-intro.md" "de5af08b90601de19c724a0c9d7c3082" "site/built/20-section2-intro.md" "2024-12-06"
19-
"episodes/21-automatically-testing-software.md" "7135961f58abfff0cb43ab4a5c463fad" "site/built/21-automatically-testing-software.md" "2025-03-07"
20-
"episodes/22-scaling-up-unit-testing.md" "049c86638afb5e99590dbf04a3f92f61" "site/built/22-scaling-up-unit-testing.md" "2025-03-07"
21-
"episodes/23-continuous-integration-automated-testing.md" "da1c3ea6300d657a78934a138e6e9bf2" "site/built/23-continuous-integration-automated-testing.md" "2025-03-07"
19+
"episodes/21-automatically-testing-software.md" "62addd6fc3732022dd238fbb8ea9739e" "site/built/21-automatically-testing-software.md" "2025-04-01"
20+
"episodes/22-scaling-up-unit-testing.md" "73bcee5ed247ef0092b202af9cc810de" "site/built/22-scaling-up-unit-testing.md" "2025-04-01"
21+
"episodes/23-continuous-integration-automated-testing.md" "2280b601a35460b220cbd621c557c6e0" "site/built/23-continuous-integration-automated-testing.md" "2025-04-01"
2222
"episodes/24-diagnosing-issues-improving-robustness.md" "b9d217dd779141be70604c0b6b13195a" "site/built/24-diagnosing-issues-improving-robustness.md" "2024-12-06"
2323
"episodes/25-section2-optional-exercises.md" "439682a4955568fa290b79ab2b486797" "site/built/25-section2-optional-exercises.md" "2024-12-06"
2424
"episodes/30-section3-intro.md" "24e70667c1848061ecb3d42ecf17dbf8" "site/built/30-section3-intro.md" "2024-12-06"
2525
"episodes/31-software-requirements.md" "adf1d73eb1d6449a95378b3f931327e2" "site/built/31-software-requirements.md" "2025-02-25"
2626
"episodes/32-software-architecture-design.md" "368bfd3da942c5aeceb2491a7203e787" "site/built/32-software-architecture-design.md" "2024-12-06"
27-
"episodes/33-code-decoupling-abstractions.md" "b8985feb5faae7512cfa3d670b23dd40" "site/built/33-code-decoupling-abstractions.md" "2025-03-10"
27+
"episodes/33-code-decoupling-abstractions.md" "05a2aa5991d7504f5a1539fe817c8d20" "site/built/33-code-decoupling-abstractions.md" "2025-04-01"
2828
"episodes/34-code-refactoring.md" "a326b0b49f7114cf0b2e56c81231c4c7" "site/built/34-code-refactoring.md" "2024-12-06"
2929
"episodes/35-software-architecture-revisited.md" "8f92fb912d61d3aded15f51020699a14" "site/built/35-software-architecture-revisited.md" "2024-12-06"
3030
"episodes/40-section4-intro.md" "d8aa3c327409db1b14826b7619287c45" "site/built/40-section4-intro.md" "2024-12-06"
31-
"episodes/41-code-review.md" "a4463fbf300f2355d3c8cfe2b917e540" "site/built/41-code-review.md" "2025-03-10"
31+
"episodes/41-code-review.md" "f075dd7ebfe2df41a3d55657ae5cc69f" "site/built/41-code-review.md" "2025-04-01"
3232
"episodes/42-software-reuse.md" "d97b8a23401a52bfb6dc5e564981fcf2" "site/built/42-software-reuse.md" "2024-12-06"
33-
"episodes/43-software-release.md" "3b29b1050dafe663d8d99d98344b0680" "site/built/43-software-release.md" "2025-03-10"
33+
"episodes/43-software-release.md" "af8aca5b2c4fb2575192c3ed74ebeb9a" "site/built/43-software-release.md" "2025-04-01"
3434
"episodes/50-section5-intro.md" "85de74adcd13ba9e8a6df600a17b9ddc" "site/built/50-section5-intro.md" "2024-12-06"
3535
"episodes/51-managing-software.md" "666be3cf81dab6bb120f649c65bd64c1" "site/built/51-managing-software.md" "2025-02-25"
3636
"episodes/52-assessing-software-suitability-improvement.md" "9092d3b746792536b43dd9d9eb1da26e" "site/built/52-assessing-software-suitability-improvement.md" "2024-12-06"
@@ -51,8 +51,8 @@
5151
"learners/reference.md" "d5d60c894664895ab3423a31bd1e2aaa" "site/built/reference.md" "2024-12-06"
5252
"learners/setup.md" "172016f61e91f7d5402d1c8ebdde32df" "site/built/setup.md" "2024-12-06"
5353
"profiles/learner-profiles.md" "60b93493cf1da06dfd63255d73854461" "site/built/learner-profiles.md" "2024-12-06"
54-
"slides/section_1_setting_up_environment.md" "fa6a35b4996b986e23b2957e329a8592" "site/built/section_1_setting_up_environment.md" "2025-03-07"
54+
"slides/section_1_setting_up_environment.md" "3f43466ae09b48d6c2e9bd6d867562ae" "site/built/section_1_setting_up_environment.md" "2025-04-01"
5555
"slides/section_2_ensuring_correctness.md" "c07cf076af61c8fdcbcfe66f6817b5e7" "site/built/section_2_ensuring_correctness.md" "2024-12-06"
5656
"slides/section_3_software_dev_process.md" "95bbcd9fd58b0c7d522b786748cb0298" "site/built/section_3_software_dev_process.md" "2024-12-06"
57-
"slides/section_4_collaborative_soft_dev.md" "a31281464ece578e328d8f1210b2770e" "site/built/section_4_collaborative_soft_dev.md" "2025-03-07"
57+
"slides/section_4_collaborative_soft_dev.md" "f729a79969cbe81f5b86cdfd1a037643" "site/built/section_4_collaborative_soft_dev.md" "2025-04-01"
5858
"slides/section_5_managing_software.md" "ee351c9e92ba29cda41bca7d2647fb1f" "site/built/section_5_managing_software.md" "2024-12-06"

0 commit comments

Comments
 (0)