Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .calkit/env-locks/remote/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cpu-count": 2
}
8 changes: 8 additions & 0 deletions .calkit/envs/py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[project]
name = "py"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
"matplotlib>=3.11.1",
"numpy>=2.5.2",
]
457 changes: 457 additions & 0 deletions .calkit/envs/py/uv.lock

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions .calkit/jobs.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
*.pyc
55 changes: 21 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,35 @@
[Project page](https://calkit.io/calkit/example-ssh) |
[GitHub repo](https://github.com/calkit/example-ssh)

A [Calkit](https://github.com/calkit/calkit) example project that
executes a command on a remote server using SSH,
automatically copying project files back and forth.
A [Calkit](https://github.com/calkit/calkit) example project that runs one
pipeline stage on another machine over SSH, and the rest locally.

Note this will probably fail if run from Windows for a Unix-like host
because Git will probably
check out files with the wrong line endings and send those over.
This is [configurable](https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings),
however.
The `raw-data` stage collects data in the `py` environment on a remote
host; `plot` then reads that data and makes a figure here.
Calkit moves the project to a workspace on that host, runs the stage there,
and brings the outputs back.

## Setup
## Getting set up and running

### Create an SSH key and add it to the agent

See [these docs](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).

This is only necessary if you haven't done this before.
Optionally, you can create a new key just for this host.
Don't use a passphrase if you want your commands to run without entering
it each time.
This should be okay if your machine is secure.

### Add your SSH key to the server

Assuming you've created one and added it to the agent, call:
There isn't a separate setup step.
Run the pipeline and Calkit asks for whatever is missing:

```sh
ssh-copy-id $USER@$HOST
calkit run
```

If created a unique key for this remote host,
use the `-i` flag to specify that key file.
In a terminal, that prompts for the host and user (saving them to `.env`),
offers to create an SSH key if you don't have one, offers to authorize this
machine on the host with `ssh-copy-id`, and offers to install Calkit there
if it's missing.
Nothing happens without you agreeing to it.

### Fill in the correct environment details

In `calkit.yaml`, there is an environment called `cluster`.
Replace any relevant values there to match your remote machine.

## Running the pipeline

Execute:
To check the setup without running anything, use:

```sh
calkit run
calkit check env -n remote
```

Outside a terminal---in CI, say---nothing is prompted for, because there's
nobody to answer.
It fails with the exact commands to run instead.
55 changes: 43 additions & 12 deletions calkit.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
dependencies:
- calkit>0.16.3
owner: calkit
name: example-ssh
hub: calkit.io
title: SSH Example
description: An example of running a Calkit pipeline stage on a remote
machine via SSH.

requirements:
- calkit>=0.44.0
- kind: env-var
name: CK_SSH_HOST

environments:
cluster:
kind: ssh
host: "10.211.55.12"
user: parallels
wdir: /home/parallels/calkit/example-ssh
key: ~/.ssh/id_ed25519
send_paths:
- script.sh
get_paths:
- results
remote:
kind: system
host: ${CK_SSH_HOST}
# Choosing a working directory is optional. It says where to put the
# project when it has to be sent here; if you're already on this host,
# stages run in the checkout you're in and this is ignored. The host is
# recognized whether it's written as a name or an address, so running
# from the machine itself skips SSH entirely.
wdir: ~/calkit/example-ssh
py:
kind: uv
path: .calkit/envs/py/pyproject.toml
python: "3.12"

pipeline:
stages:
raw-data:
kind: python-script
script_path: scripts/collect.py
environment: remote:py
outputs:
- path: data/raw.csv
storage: git
plot:
kind: python-script
script_path: scripts/plot.py
environment: py
inputs:
- data/raw.csv
outputs:
- figures/plot.png
201 changes: 201 additions & 0 deletions data/raw.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
t,signal
0.0,0.01257302210933933
0.06314759102693052,0.04989514498354346
0.12629518205386103,0.19000197011204578
0.18944277308079155,0.19880167820502184
0.25259036410772207,0.19634602505419727
0.3157379551346526,0.3466775373651173
0.3788855461615831,0.5002852899295606
0.4420331371885136,0.5224861640231339
0.5051807282154441,0.4135920775621395
0.5683283192423747,0.4116817586196833
0.6314759102693052,0.5280092456827932
0.6946235012962356,0.6442288208618314
0.7577710923231662,0.45480106514530083
0.8209186833500968,0.7098930999738222
0.8840662743770272,0.6487322364900325
0.9472138654039577,0.7385649669506755
1.0103614564308883,0.7925981354865679
1.0735090474578188,0.8472498632245449
1.1366566384847494,0.9483953045828947
1.1998042295116798,1.0362194660967026
1.2629518205386103,0.9401354427214358
1.326099411565541,1.1068571425959548
1.3892470025924712,0.9170456698877085
1.4523945936194018,1.0281497067879717
1.5155421846463324,1.0888208963855597
1.578689775673263,1.0093700766702438
1.6418373667001935,0.9231277214809579
1.7049849577271239,0.8988376698169501
1.7681325487540545,0.9348197285156702
1.831280139780985,0.9882849984730268
1.8944277308079154,0.8471250251466359
1.957575321834846,0.90521129112067
2.0207229128617765,0.8845565314653039
2.083870503888707,0.9253242012070404
2.1470180949156377,0.8599931484880114
2.210165685942568,0.8380094851055702
2.273313276969499,0.6978354415833344
2.336460867996429,0.7079606154454394
2.3996084590233595,0.7541493956297418
2.4627560500502903,0.7772310878629344
2.5259036410772207,0.4516145992031766
2.589051232104151,0.6762445402383748
2.652198823131082,0.6046785008142335
2.715346414158012,0.4915869737221769
2.7784940051849425,0.38161811566635895
2.8416415962118733,0.2640811681810273
2.9047891872388036,0.3803985711460648
2.9679367782657344,0.3688102171190959
3.031084369292665,0.2904469858978876
3.094231960319595,0.1788533664449952
3.157379551346526,0.019951799052258582
3.2205271423734563,-0.1996844086356935
3.283674733400387,-0.1420499327369601
3.3468223244273174,-0.13814452278251854
3.4099699154542478,-0.39400328477363394
3.4731175064811786,-0.285973020492011
3.536265097508109,-0.34151946554978774
3.5994126885350393,-0.37238941810929205
3.66256027956197,-0.616131426151402
3.7257078705889004,-0.6176317692070108
3.7888554616158308,-0.6466486318939364
3.8520030526427615,-0.7691251378924729
3.915150643669692,-0.524748358280293
3.9782982346966227,-0.7920312537734984
4.041445825723553,-0.7503386685728702
4.104593416750483,-0.8467661296766549
4.167741007777414,-0.6969624472801994
4.230888598804345,-0.7542649809850249
4.294036189831275,-0.8504241058549452
4.357183780858206,-1.15792613176549
4.420331371885136,-0.9524505722899408
4.483478962912066,-0.9055456890078842
4.546626553938998,-0.8858966807537858
4.609774144965928,-1.0565304204914172
4.672921735992858,-0.8170201330684433
4.736069327019789,-1.1317627306948073
4.799216918046719,-1.0623856244525287
4.862364509073649,-0.8952697357756004
4.925512100100581,-0.9724696393841761
4.988659691127511,-0.7618401047299374
5.051807282154441,-0.9240965756161905
5.114954873181372,-0.9833781663573973
5.178102464208302,-0.9312577462381552
5.241250055235233,-0.9724968871931428
5.304397646262164,-0.9575894767743865
5.367545237289094,-0.7299115840059553
5.430692828316024,-0.6948064825920965
5.493840419342955,-0.5804361404472214
5.556988010369885,-0.7394917222364248
5.620135601396816,-0.44661249566381167
5.683283192423747,-0.5933004532927847
5.746430783450677,-0.35390878775786816
5.809578374477607,-0.4993777439252759
5.872725965504538,-0.4725788869665689
5.935873556531469,-0.31539276624824597
5.999021147558399,-0.17720992073006708
6.06216873858533,-0.20312061917615698
6.12531632961226,-0.21576692537958472
6.18846392063919,-0.22870177920251228
6.2516115116661215,-0.17172057125655305
6.314759102693052,0.08183683475229721
6.377906693719982,0.19355111112342538
6.4410542847469126,0.1407845837047215
6.504201875773843,0.11178509102484747
6.567349466800774,0.3676594444791854
6.6304970578277045,0.21233190893265572
6.693644648854635,0.32772374822641376
6.756792239881565,0.5182009445610257
6.8199398309084955,0.2863354982848672
6.883087421935426,0.6031986422685482
6.946235012962357,0.5573591572672291
7.0093826039892875,0.6749591128582128
7.072530195016218,0.7023218697692505
7.135677786043148,0.7731345033377728
7.1988253770700785,0.8623699267534792
7.26197296809701,0.7539844850458851
7.32512055912394,1.0054804776624149
7.3882681501508705,0.9661107746096506
7.451415741177801,1.0044320235685014
7.514563332204731,1.0594348929785398
7.5777109232316615,1.0408381852650497
7.640858514258593,1.0617829688245666
7.704006105285523,0.9963340956612912
7.7671536963124534,0.8535554371720335
7.830301287339384,0.9862151236897766
7.893448878366314,0.922269805383605
7.956596469393245,0.8524655391691156
8.019744060420175,1.0121381174293016
8.082891651447106,0.9170593626707736
8.146039242474037,0.854673025914783
8.209186833500967,0.8332750356936687
8.272334424527898,0.9406010761083281
8.335482015554827,0.9221682746102435
8.398629606581759,0.9875554821370952
8.46177719760869,0.8195174082768528
8.52492478863562,0.8874196074401729
8.58807237966255,0.8826666636065351
8.65121997068948,0.8137017096082763
8.714367561716411,0.41561455648748924
8.777515152743343,0.7258734790999561
8.840662743770272,0.585423512827972
8.903810334797203,0.5400967647610175
8.966957925824133,0.47911643227920564
9.030105516851064,0.4227815510590869
9.093253107877995,0.3574266485354491
9.156400698904925,0.22927580754481697
9.219548289931856,0.013628486452552269
9.282695880958785,0.13071304663420996
9.345843471985717,-0.0015206394445912569
9.408991063012646,0.12380258326742648
9.472138654039577,-0.07621964057109547
9.535286245066509,-0.1019359633005745
9.598433836093438,-0.25774498103511323
9.66158142712037,-0.2856587495821815
9.724729018147299,-0.2966267558033278
9.78787660917423,-0.5037100710597827
9.851024200201161,-0.38338732222267397
9.91417179122809,-0.4806981837807776
9.977319382255022,-0.6434241432649919
10.040466973281951,-0.8173444389533651
10.103614564308883,-0.5765827599528277
10.166762155335814,-0.7055102525179422
10.229909746362743,-0.7739228201365318
10.293057337389675,-0.7868337655104628
10.356204928416604,-0.6208246201134631
10.419352519443535,-0.8435073331433417
10.482500110470466,-0.8625777164396057
10.545647701497396,-1.0491863194242912
10.608795292524327,-0.7613949419722312
10.671942883551257,-0.8563380451560799
10.735090474578188,-0.8595719994255039
10.79823806560512,-0.9758250379612362
10.861385656632049,-0.8993447285603325
10.92453324765898,-0.9603829629068978
10.98768083868591,-0.9386499391082557
11.05082842971284,-1.0136931740612078
11.11397602073977,-1.1403874945828656
11.177123611766701,-0.8806797024560516
11.240271202793632,-1.163706759201957
11.303418793820562,-0.9769825761416431
11.366566384847493,-0.952420377992401
11.429713975874423,-1.0115182650439323
11.492861566901354,-0.8175675652278025
11.556009157928285,-0.8670570039132555
11.619156748955215,-0.8554785349807493
11.682304339982146,-0.7213391581175749
11.745451931009075,-0.7794301704229188
11.808599522036006,-0.5484061451253537
11.871747113062938,-0.6049507153083755
11.934894704089867,-0.6377699906199727
11.998042295116798,-0.7326504033228429
12.061189886143728,-0.6147409208329543
12.12433747717066,-0.3190949892333734
12.18748506819759,-0.3749456917276806
12.25063265922452,-0.3388305384421228
12.313780250251451,-0.08558780094603849
12.37692784127838,-0.31657659089710855
12.440075432305312,-0.18452548505185362
12.503223023332243,-0.11036439898852149
12.566370614359172,0.05863372815312955
41 changes: 41 additions & 0 deletions dvc.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,44 @@ stages:
md5: 744952094a9dd0720499e19bae8018d6.dir
size: 8
nfiles: 2
raw-data:
cmd: calkit xenv -n remote --no-check -- calkit xenv -n py --no-check -- python
scripts/collect.py
deps:
- path: .calkit/env-locks/remote/info.json
hash: md5
md5: 17f4ca0df24b3de27e52f7e3349a6dde
size: 21
- path: .calkit/envs/py/uv.lock
hash: md5
md5: 42a6bb483bf62e9c50141357e3f934d6
size: 111884
- path: scripts/collect.py
hash: md5
md5: 5e90799577a974131ba41936a4572a5e
size: 952
outs:
- path: data/raw.csv
hash: md5
md5: 0841adb5f537addcefff8632579fbb98
size: 7804
plot:
cmd: calkit xenv -n py --no-check -- python scripts/plot.py
deps:
- path: .calkit/envs/py/uv.lock
hash: md5
md5: 42a6bb483bf62e9c50141357e3f934d6
size: 111884
- path: data/raw.csv
hash: md5
md5: 0841adb5f537addcefff8632579fbb98
size: 7804
- path: scripts/plot.py
hash: md5
md5: 11c2636e9009187d57ca797d6d64bde5
size: 1016
outs:
- path: figures/plot.png
hash: md5
md5: 0cd9cc7514f58a76a516866f163db662
size: 45260
Loading