Skip to content

Commit 1b9f5c7

Browse files
authored
Merge pull request #22 from acceleratescience/fix/fg-workshop
Workshop fixes
2 parents a3b2181 + a743bb3 commit 1b9f5c7

File tree

10 files changed

+164
-116
lines changed

10 files changed

+164
-116
lines changed

docs/1_setting_up.md

Lines changed: 85 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,37 @@
1-
## Setting up Codespaces
2-
The first step is to fork this repository to your own GitHub account. This will allow you to make changes to the code without affecting the original repository.
3-
4-
Now head back over to your newly created repo. Everything in the `main` repo is not needed, so we do a few things:
5-
6-
**Change the default branch**
7-
8-
- Head to the Repo Settings
9-
- There is a heading called "Default Branch"
10-
- Click on the two arrow icon and change the default branch to `basic`
1+
## Setting up Pods
112

12-
**Delete the `main` branch**
3+
`Pods` is our teaching platform for hands-on programming. It standardises the training workshop by giving everyone an identical Docker container and operating system, so we avoid the classic “this doesn’t work on my machine” problem.
4+
That said, if you run into any issues, please feel free to raise your hand. The steps for setup will be outlined in the early stages of the workshop, but they are included below too:
135

14-
- Head back to the Code tab
15-
- Locate the branch dropdown and click on the thing to the right of it (it should say `4 branches`)
16-
- Find the `main` branch and delete it
6+
1. Head to [pods.acceleratescience.co.uk](https://pods.acceleratescience.co.uk)
7+
2. Username = [CRSid], password will be provided in the workshop
178

18-
**Rename the `basic` branch to `main`**
9+
![](imgs/pods.png)
1910

20-
- In the same page for the `basic` branch, next to the trash can, click on the three dots
21-
- Click on "Rename branch"
22-
- Change the name to `main`
23-
24-
**Rename the repo**
25-
26-
- Head back over to the Settings tab
27-
- At the top, you can change the name of the repo to whatever you want
28-
- Rename it to `cancer-prediction-<your-crsid>`
29-
30-
Now open Codespaces on `main`:
31-
32-
![](imgs/createcodespace.png)
33-
34-
You should now be in the browser version of VSCode.
35-
36-
This is the absolute most basic version of code being submitted to GitHub. But we can do better...
37-
38-
!!! note
39-
40-
Even though we are using Codespaces, the general packaging process will still work with regular VSCode on your desktop.
11+
3. You should see a screen like above. Click VSCode/JupyterLab to open the IDE in your browser!
4112

4213
## Create a new branch
14+
We are going to start by initialising a git repository in our directory
15+
```bash
16+
git init
17+
```
18+
We also need to create and set an `origin` for our git repository, that is a repository hosted on GitHub that we can push our changes to. The first step is to head to GitHub and create a new repository with the name:
19+
```
20+
cancer-prediction-<your-CRSId>
21+
```
22+
If we now return to our IDE and ask for the remote repository
23+
```bash
24+
git remote -v
25+
```
26+
nothing is returned. To set this to our newly created GitHub repository, simply run:
27+
```bash
28+
git remote add origin https://github.com/username/repository-name.git
29+
```
30+
Now, `git remote -v` should return:
31+
```bash
32+
origin https://github.com/username/cancer-prediction-CRSId.git (fetch)
33+
origin https://github.com/username/cancer-prediction-CRSId.git (push)
34+
```
4335
It is good practice to do development work on a new branch, but first we should set up a virtual environment and install any dependencies.
4436

4537
Set up the new virtual environment with,
@@ -74,15 +66,6 @@ and populate it with boiler plate text. If you have Copilot, it will do it for y
7466

7567
Once you update, all the additional files should vanish from the staging area. Once this is done, commit the changes, and sync the remote version with the local version.
7668

77-
Now create a new branch using the UI or using the git CLI.
78-
```bash
79-
git checkout -b dev
80-
```
81-
82-
This will automatically create and move over to a new branch called `dev`. The environment and all the packages we installed should also be moved along with it.
83-
84-
In the source control tab, hit "Publish Branch".
85-
8669
When you see this symbol:
8770

8871
<br>
@@ -91,6 +74,15 @@ When you see this symbol:
9174

9275
it means that you should commit and push your changes to the repository. They indicate key checkpoints in the workshop.
9376

77+
In the source control tab, hit "Publish Branch".
78+
79+
Now create a new branch using the UI or using the git CLI.
80+
```bash
81+
git checkout -b dev
82+
```
83+
84+
This will automatically create and move over to a new branch called `dev`. The environment and all the packages we installed should also be moved along with it. We will use this for developing new features in the codebase. Publish this branch using the same method as before.
85+
9486
## Further reading
9587
<div class="grid cards" markdown>
9688

@@ -99,4 +91,51 @@ it means that you should commit and push your changes to the repository. They in
9991
---
10092
Information on Git/GitHub, Codespaces, VSCode
10193

102-
</div>
94+
</div>
95+
96+
## Setting up Codespaces (*Legacy*)
97+
98+
!!! warning
99+
100+
We no longer use CodeSpaces in our workshops, and instead make use of our shiny new platform `Pods`. This is included here purely as a fallback option.
101+
102+
103+
The first step is to fork this repository to your own GitHub account. This will allow you to make changes to the code without affecting the original repository.
104+
105+
Now head back over to your newly created repo. Everything in the `main` repo is not needed, so we do a few things:
106+
107+
**Change the default branch**
108+
109+
- Head to the Repo Settings
110+
- There is a heading called "Default Branch"
111+
- Click on the two arrow icon and change the default branch to `basic`
112+
113+
**Delete the `main` branch**
114+
115+
- Head back to the Code tab
116+
- Locate the branch dropdown and click on the thing to the right of it (it should say `4 branches`)
117+
- Find the `main` branch and delete it
118+
119+
**Rename the `basic` branch to `main`**
120+
121+
- In the same page for the `basic` branch, next to the trash can, click on the three dots
122+
- Click on "Rename branch"
123+
- Change the name to `main`
124+
125+
**Rename the repo**
126+
127+
- Head back over to the Settings tab
128+
- At the top, you can change the name of the repo to whatever you want
129+
- Rename it to `cancer-prediction-<your-crsid>`
130+
131+
Now open Codespaces on `main`:
132+
133+
![](imgs/createcodespace.png)
134+
135+
You should now be in the browser version of VSCode.
136+
137+
This is the absolute most basic version of code being submitted to GitHub. But we can do better...
138+
139+
!!! note
140+
141+
Even though we are using Codespaces, the general packaging process will still work with regular VSCode on your desktop.

docs/4_Testing.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ if __name__ == '__main__':
6969
```
7070
</details>
7171

72+
!!! warning
73+
Remember to update your import to be from package `cancer_prediction_<your-CRSId>`, as opposed to the generic `cancer_prediction` we have here.
74+
7275
## Running tests
7376
### In the VSCode UI
7477
To run the tests, we click on the "Testing" tab on the sidebar, and then "Configure Python Tests". The order of clicks is as follows:
@@ -95,13 +98,16 @@ OK
9598

9699
You can try changing part of the test code to force them to fail, and check the output. Now that the tests have run succesfully, it's time to commit and push the changes.
97100

101+
!!! note
102+
If the tests fail due to an import error of your `cancer_prediction_<your-CRSId>.cancer_model` file, try running `uv sync` then re-running the test command.
103+
98104
<br>
99105
![Dark Souls Bonfire](../imgs/dark-souls-bonfire.gif "Commit your changes and rest, weary traveller"){ width="50" .center }
100106
<br>
101107

102108
!!! note
103109

104-
For some reason Codespaces is not discovering the tests. Just run them in the terminal for now. But VSCode run locally should work fine.
110+
If for some reason the VSCode UI is not discovering the tests, try refreshing the VSCode window. If you're still having trouble, just run them in the terminal for now.
105111

106112
## Further reading
107113
<div class="grid cards" markdown>

docs/CICD/documentation.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ on:
1111
jobs:
1212
build-docs:
1313
needs: tests
14-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
14+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
1515
runs-on: ubuntu-latest
1616

1717
steps:
1818
- uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
2121

22-
- name: Verify tag is on main
22+
- name: Verify tag is on master
2323
run: |
2424
# Get the branch containing this tag
25-
BRANCH=$(git branch -r --contains ${{ github.ref }} | grep 'main' || true)
25+
BRANCH=$(git branch -r --contains ${{ github.ref }} | grep 'master' || true)
2626
27-
# Check if the tag is on main
27+
# Check if the tag is on master
2828
if [ -z "$BRANCH" ]; then
29-
echo "Error: Tag must be created on main branch"
29+
echo "Error: Tag must be created on master branch"
3030
exit 1
3131
fi
3232
@@ -79,15 +79,15 @@ In addition, since we are using some tools, we should let everyone know! So we c
7979
which should display as the following:
8080
![](../imgs/badges.png)
8181

82-
Before we push these changes, we will configure GitHub Pages so that our documentation will create a url for people to visit. Go to the repo Settings -> Pages, and pick a branch to deploy from, in this case 'gh-pages'. So now when we push these changes and merge them to `main`, the documentation will be published and the badges will be displayed on the README!
82+
Before we push these changes, we will configure GitHub Pages so that our documentation will create a url for people to visit. Go to the repo Settings -> Pages, and pick a branch to deploy from, in this case 'gh-pages'. So now when we push these changes and merge them to `master`, the documentation will be published and the badges will be displayed on the README!
8383

8484
!!! tip
8585

8686
You can in principle delete the 'dev' branch whenever you build your package. But if for whatever reason you decide to keep it, be sure to do the following
8787
```bash
8888
git checkout dev
8989
git fetch origin
90-
git merge origin/main
90+
git merge origin/master
9191
```
9292

93-
This will ensure that the 'dev' branch is up to date with the 'main' branch. Do this BEFORE you make any changes to the 'dev' branch, otherwise you have to merge the changes manually.
93+
This will ensure that the 'dev' branch is up to date with the 'master' branch. Do this BEFORE you make any changes to the 'dev' branch, otherwise you have to merge the changes manually.

docs/CICD/publishing.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Finally, we will automate the publishing of our package to PyPI and the release of the documentation.
22

33
## Pull requests
4-
When do we want to publish our package and documentation? We don't want to publish when we push changes to `dev`, because there might be some experimental changes that we've made that could break our package. Instead we should restrict publishing only when there are pushes made to `main`. However, we don't just want to push changes to main directly.
4+
When do we want to publish our package and documentation? We don't want to publish when we push changes to `dev`, because there might be some experimental changes that we've made that could break our package. Instead we should restrict publishing only when there are pushes made to `master`. However, we don't just want to push changes to `master` directly.
55

66
Head over to the repo and submit a pull request. It should look something like this:
77

88
![](../imgs/PR.png)
99

10-
You should make sure that the `compare` branch is `dev` and the `base` branch is `main`.
10+
You should make sure that the `compare` branch is `dev` and the `base` branch is `master`.
1111

1212
!!! warning
1313

@@ -19,11 +19,11 @@ There are no conflicts so I can merge these branches without any issues. If ther
1919

2020
Notice that there are some checks happening. We want to avoid hitting that Merge pull request button as long as those checks have not passed. We can actually enforce this, but for now we can just manually make sure that the checks have passed.
2121

22-
Now head over to the Code tab and click on the branches. Delete the `dev` branch. We don't need it anymore. When you head back into codespaces, checkout the `main` branch and pull any changes by running these commands:
22+
Now head over to the Code tab and click on the branches. Delete the `dev` branch. We don't need it anymore. When you head back into codespaces, checkout the `master` branch and pull any changes by running these commands:
2323

2424
```bash
25-
git checkout main
26-
git pull origin main
25+
git checkout master
26+
git pull origin master
2727
```
2828

2929
We will create a new branch for adding our publishing workflow:
@@ -53,11 +53,11 @@ jobs:
5353
with:
5454
fetch-depth: 0
5555

56-
- name: Verify tag is on main
56+
- name: Verify tag is on master
5757
run: |
58-
BRANCH=$(git branch -r --contains ${{ github.ref }} | grep 'main' || true)
58+
BRANCH=$(git branch -r --contains ${{ github.ref }} | grep 'master' || true)
5959
if [ -z "$BRANCH" ]; then
60-
echo "Error: Tag must be created on main branch"
60+
echo "Error: Tag must be created on master branch"
6161
exit 1
6262
fi
6363
@@ -115,19 +115,19 @@ As before, we name the workflow. Now though, we have a peculiar `#!yaml tag` con
115115
The main job here is the `#!yaml release`. We look at some key components
116116

117117
```yaml
118-
- name: Verify tag is on main
118+
- name: Verify tag is on master
119119
run: |
120120
# Get the branch containing this tag
121-
BRANCH=$(git branch -r --contains ${{ github.ref }} | grep 'main' || true)
121+
BRANCH=$(git branch -r --contains ${{ github.ref }} | grep 'master' || true)
122122
123-
# Check if the tag is on main
123+
# Check if the tag is on master
124124
if [ -z "$BRANCH" ]; then
125-
echo "Error: Tag must be created on main branch"
125+
echo "Error: Tag must be created on master branch"
126126
exit 1
127127
fi
128128
```
129129

130-
This does exactly what you think it does! It checks if the tag is on the `main` branch. If it is not, it will throw an error and the workflow will stop.
130+
This does exactly what you think it does! It checks if the tag is on the `master` branch. If it is not, it will throw an error and the workflow will stop.
131131

132132
The next interesting part is
133133
```yaml
@@ -173,37 +173,37 @@ The final section builds the package and releases it to GitHub and to Test PyPI.
173173
There are two main schools of development on git: Git Flow, and trunk-based development.
174174

175175
#### Git Flow
176-
In Git Flow you have two long-running branches `main` and `dev`. Workers will usually branch off of `dev`, make some feature change, then submit a PR. The PR is accepted (or not) and merged to `dev`. When we are happy, we create a release branch, do some tests, and then merge this branch into `main` and tag it with a release. This style is very suitable to open-source projects, where you can't trust random people trying to make changes to your code.
176+
In Git Flow you have two long-running branches `master` and `dev`. Workers will usually branch off of `dev`, make some feature change, then submit a PR. The PR is accepted (or not) and merged to `dev`. When we are happy, we create a release branch, do some tests, and then merge this branch into `master` and tag it with a release. This style is very suitable to open-source projects, where you can't trust random people trying to make changes to your code.
177177

178178
#### Trunk
179-
In Trunk-based development, you work from a single `main` branch. Usually you work from it directly, and make short changes, and make small `feature` branches. Development is fast and continuous. When you are happy, you create a separate `release` branch which is pushed to PyPI (or wherever). This is a great option for small, speedy projects, and is the approach that we use here.
179+
In Trunk-based development, you work from a single `master` branch. Usually you work from it directly, and make short changes, and make small `feature` branches. Development is fast and continuous. When you are happy, you create a separate `release` branch which is pushed to PyPI (or wherever). This is a great option for small, speedy projects, and is the approach that we use here.
180180

181181
!!! tip
182182

183-
If you find yourself working on a feature, and somebody has made changes to the main branch, you can update yours by running
183+
If you find yourself working on a feature, and somebody has made changes to the master branch, you can update yours by running
184184
```bash
185185
git checkout dev
186-
git merge origin/main
186+
git merge origin/master
187187
```
188-
This will update your `dev` branch with the changes from `main`.
188+
This will update your `dev` branch with the changes from `master`.
189189

190190
## Actually publishing
191-
Submit a PR, and merge the changes into main. If we've done everything correct, the workflow should not run.
191+
Submit a PR, and merge the changes into master. If we've done everything correct, the workflow should not run.
192192

193-
Back in Codespaces, checkout the `main` branch and pull any changes:
193+
Back in Codespaces, checkout the `master` branch and pull any changes:
194194

195195
```bash
196-
git checkout main
197-
git pull origin main
196+
git checkout master
197+
git pull origin master
198198
```
199199

200-
Bump the version (because if we try to push this versoin again, it will fail), and push the changes:
200+
Bump the version (because if we try to push this version again, it will fail), and push the changes:
201201

202202
```bash
203203
uv version patch
204204
git add pyproject.toml
205205
git commit -m "Bump version to $(uv version --short)"
206-
git push origin main
206+
git push origin master
207207
```
208208

209209
Now, create a new tag and push it:

docs/CICD/testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ name: Run Tests
1717
on:
1818
push:
1919
branches-ignore:
20-
- main
20+
- master
2121

2222
jobs:
2323
pre-commit:
@@ -64,10 +64,10 @@ name: Run Tests
6464
on:
6565
push:
6666
branches-ignore:
67-
- main
67+
- master
6868
```
6969
70-
We give the workflow a name `Run Tests`. Then we say, whenever a push is made to any branch other than `main`, run this workflow.
70+
We give the workflow a name `Run Tests`. Then we say, whenever a push is made to any branch other than `master`, run this workflow.
7171

7272
### The jobs
7373
Next, we define what `jobs` we want to run. In this case we have two: the `pre-commit`, and the `tests`.

0 commit comments

Comments
 (0)