Skip to content

Commit 57f8c84

Browse files
authored
Developer Mode (#571)
* Removes the `$HOME/PlanktoScope/.git` folder on cleanup to save some space * Introduced a non-public `enable-developer-mode` script to reinitializes the repo * Document the developer mode in the tips and tricks section
1 parent 2b7fa59 commit 57f8c84

File tree

4 files changed

+90
-4
lines changed

4 files changed

+90
-4
lines changed

documentation/docs/community/contribute/tips-and-tricks.md

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
# Tips and tricks
22

3+
34
This page provides useful snippets and how-tos while developing software for the PlanktoScope.
45

56
!!! warning
67

78
This document is meant for PlanktoScope developers. Proceed with care.
89

9-
## Development Environment
10+
- [Development OS](#development-os)
11+
- [Development Environment](#development-environment)
12+
- [Connect to router](#connect-to-router)
13+
- [Disable splash screen](#disable-splash-screen)
14+
- [Backup and Restore SD Card](#backup-and-restore-sd-card)
15+
- [Documentation quick setup](#documentation-quick-setup)
16+
- [Test dataset for segmenter](#test-dataset-for-segmenter)
17+
18+
## Development OS
1019

1120
On the Raspberry, we recommend using our developer image which is built upon [Raspberry Pi OS with desktop 64-bit](https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit).
1221

@@ -19,6 +28,66 @@ You can find the latest build in [actions](https://github.com/PlanktoScope/Plank
1928

2029
See [Backup and Restore SD Card image](#backup-and-restore-sd-card) below to write the `.img.xz` file to the sdcard
2130

31+
## Development Environment
32+
33+
To setup the recommended development environment, run the following commands.
34+
35+
Make sure to replace `$planktoscope` with your PlanktoScope hostname, eg. `pkscope-sponge-bob-123`
36+
37+
<details>
38+
<summary>On the PlanktoScope</summary>
39+
40+
```sh
41+
cd ~/Planktoscope
42+
# Enable Developer Mode
43+
./software/distro/setup/planktoscope-app-env/PlanktoScope/enable-developer-mode
44+
# Configure git
45+
git config --global user.email "you@example.com"
46+
git config --global user.name "Your Name"
47+
```
48+
</details>
49+
50+
<details>
51+
<summary>On your computer</summary>
52+
53+
```sh
54+
# Create an SSH key for the PlanktoScope specifically
55+
ssh-keygen -t ed25519 -C "pi@$planktoscope" -f ~/.ssh/$planktoscope
56+
# Make the SSH key accepted by the PlanktoScope
57+
scp ~/.ssh/$planktoscope.pub pkscope:~/.ssh/authorized_keys
58+
```
59+
60+
```
61+
# Add the following to ~/.ssh/config
62+
Host $planktoscope
63+
# https://docs.github.com/en/authentication/connecting-to-github-with-ssh/using-ssh-agent-forwarding
64+
ForwardAgent yes
65+
User pi
66+
IdentityFile ~/.ssh/planktoscope
67+
```
68+
69+
</details>
70+
71+
---
72+
73+
You can now SSH into your PlanktoScope without username / password (using `ssh $planktoscope`) and use `~/PlanktoScope` as a regular git repository.
74+
75+
```sh
76+
ssh $planktoscope
77+
cd PlanktoScope
78+
git status
79+
git checkout master
80+
```
81+
82+
We recommend developping directly from the PlanktoScope using [Visual Studio Code and the Remote - SSH extension](https://code.visualstudio.com/docs/remote/ssh).
83+
Use `$planktoscope` as the host to connect to and open the "PlanktoScope" directory.
84+
85+
If you make changes to the backend, you can restart the backend and test your changes with
86+
87+
```sh
88+
sudo systemctl restart planktoscope-org.device-backend.controller-planktoscopehat.service
89+
```
90+
2291
## Connect to router
2392

2493
The default behavior of the PlanktoScope is to act as a router to connect your computer to it directly via WiFi or Ethernet.
@@ -145,14 +214,14 @@ which you can use for testing the segmenter.
145214
To use it, first download it as a `.zip` archive, e.g. to
146215
`~/Downloads/BTS2023_S3_A2-TIMESTAMP-001.zip`. Then extract it:
147216

148-
```
217+
```sh
149218
unzip BTS2023_S3_A2-TIMESTAMP-001.zip
150219
```
151220

152221
This will result in a new directory named `BTS2023_S3_A2`. Upload that new directory into the
153222
PlanktoScope's `data/img` directory, e.g. via SCP:
154223

155-
```
224+
```sh
156225
scp -r BTS2023_S3_A2 pi@planktoscope.local:~/data/img
157226
```
158227

software/distro/setup/cleanup.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ else
4747
fi
4848
fi
4949

50-
5150
description="remove unnecessary artifacts from the base operating system"
5251
report_starting "$description"
5352
if $setup_scripts_root/base-os/cleanup.sh ; then
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/env -S bash -eux
2+
3+
sudo apt install yq -y
4+
5+
commit=$(yq -r '.commit' /usr/share/planktoscope/installer-versioning.yml)
6+
7+
cd $HOME/PlanktoScope
8+
git init --initial-branch=master
9+
git remote add origin git@github.com:PlanktoScope/PlanktoScope.git
10+
git fetch origin --filter=blob:none
11+
# "Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated."
12+
# https://git-scm.com/docs/git-reset#Documentation/git-reset.txt---mixed
13+
git reset --mixed $commit
14+
15+
mkdir $HOME/.ssh

software/distro/setup/planktoscope-app-env/cleanup.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash -eux
22
# Cleanup removes unnecessary files from the operating system for a smaller and more secure disk image.
33

4+
# Clear git repo - can be re-init with enable-developer-mode.sh
5+
rm -rf $HOME/PlanktoScope/.git
6+
47
# Clean up any unnecessary apt files
58
sudo apt-get autoremove -y
69
sudo apt-get clean -y

0 commit comments

Comments
 (0)