liboxen 0.50.0

Oxen is a fast, unstructured data version control, to help version large machine learning datasets written in Rust.
Documentation
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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
use crate::api;
use crate::api::client;
use crate::error::OxenError;
use crate::model::RemoteRepository;
use crate::model::commit::NewCommitBody;
use crate::view::CommitResponse;

use bytes::{Bytes, BytesMut};
use futures_util::StreamExt;
use reqwest::multipart::{Form, Part};
use std::path::Path;

pub async fn put_file(
    remote_repo: &RemoteRepository,
    branch: impl AsRef<str>,
    directory: impl AsRef<str>,
    file_path: impl AsRef<Path>,
    file_name: Option<impl AsRef<str>>,
    commit_body: Option<NewCommitBody>,
) -> Result<CommitResponse, OxenError> {
    let branch = branch.as_ref();
    let directory = directory.as_ref();
    put_multipart_file(
        remote_repo,
        format!("/file/{branch}/{directory}"),
        "files[]",
        file_path,
        file_name,
        commit_body,
    )
    .await
}

pub async fn put_file_to_path(
    remote_repo: &RemoteRepository,
    branch: impl AsRef<str>,
    file_path_on_repo: impl AsRef<str>,
    file_path: impl AsRef<Path>,
    file_name: Option<impl AsRef<str>>,
    commit_body: Option<NewCommitBody>,
) -> Result<CommitResponse, OxenError> {
    let branch = branch.as_ref();
    let file_path_on_repo = file_path_on_repo.as_ref();
    put_multipart_file(
        remote_repo,
        format!("/file/{branch}/{file_path_on_repo}"),
        "file",
        file_path,
        file_name,
        commit_body,
    )
    .await
}

async fn put_multipart_file(
    remote_repo: &RemoteRepository,
    uri: String,
    field_name: &'static str,
    file_path: impl AsRef<Path>,
    file_name: Option<impl AsRef<str>>,
    commit_body: Option<NewCommitBody>,
) -> Result<CommitResponse, OxenError> {
    let file_path = file_path.as_ref();
    log::debug!("put_multipart_file {uri:?}, file_path {file_path:?}");
    let url = api::endpoint::url_from_repo(remote_repo, &uri)?;
    let client = client::new_for_url(&url)?;

    let file_part = make_file_part(file_path, file_name).await?;
    let form = apply_commit_body(Form::new().part(field_name, file_part), commit_body);
    let res = client.put(&url).multipart(form).send().await?;
    let body = client::parse_json_body(&url, res).await?;
    Ok(serde_json::from_str(&body)?)
}

async fn make_file_part(
    file_path: &Path,
    file_name: Option<impl AsRef<str>>,
) -> Result<Part, OxenError> {
    let file_part = Part::file(file_path).await?;
    Ok(match file_name {
        Some(file_name) => file_part.file_name(file_name.as_ref().to_string()),
        None => file_part,
    })
}

fn apply_commit_body(mut form: Form, commit_body: Option<NewCommitBody>) -> Form {
    if let Some(body) = commit_body {
        form = form.text("name", body.author);
        form = form.text("email", body.email);
        form = form.text("message", body.message);
    }
    form
}

pub async fn get_file(
    remote_repo: &RemoteRepository,
    branch: impl AsRef<str>,
    file_path: impl AsRef<Path>,
) -> Result<Bytes, OxenError> {
    get_file_with_params(remote_repo, branch, file_path, None, None, None, None).await
}

/// Get a file with optional query parameters (for thumbnails, image resizing, etc.)
pub async fn get_file_with_params(
    remote_repo: &RemoteRepository,
    branch: impl AsRef<str>,
    file_path: impl AsRef<Path>,
    thumbnail: Option<bool>,
    width: Option<u32>,
    height: Option<u32>,
    timestamp: Option<f64>,
) -> Result<Bytes, OxenError> {
    let branch = branch.as_ref();
    let path_ref = file_path.as_ref();
    let file_path = path_ref
        .to_str()
        .ok_or_else(|| OxenError::basic_str(format!("Invalid UTF-8 in file path: {path_ref:?}")))?;
    let uri = format!("/file/{branch}/{file_path}");
    let url = api::endpoint::url_from_repo(remote_repo, &uri)?;

    let client = client::new_for_url(&url)?;

    // Build query parameters only for Some(...) values
    let mut query_params: Vec<(&str, String)> = Vec::new();
    if let Some(thumb) = thumbnail {
        query_params.push(("thumbnail", thumb.to_string()));
    }
    if let Some(w) = width {
        query_params.push(("width", w.to_string()));
    }
    if let Some(h) = height {
        query_params.push(("height", h.to_string()));
    }
    if let Some(ts) = timestamp {
        query_params.push(("timestamp", ts.to_string()));
    }

    let req = client.get(&url).query(&query_params);

    let res = req.send().await?;

    let res = res.error_for_status()?;
    let mut stream = res.bytes_stream();
    let mut buffer = BytesMut::new();
    while let Some(chunk_result) = stream.next().await {
        let chunk =
            chunk_result.map_err(|e| OxenError::basic_str(format!("Failed to read chunk: {e}")))?;
        buffer.extend_from_slice(&chunk);
    }

    Ok(buffer.freeze())
}

/// Get a video thumbnail
pub async fn get_file_thumbnail(
    remote_repo: &RemoteRepository,
    branch: impl AsRef<str>,
    file_path: impl AsRef<Path>,
    width: Option<u32>,
    height: Option<u32>,
    timestamp: Option<f64>,
) -> Result<Bytes, OxenError> {
    get_file_with_params(
        remote_repo,
        branch,
        file_path,
        Some(true),
        width,
        height,
        timestamp,
    )
    .await
}

/// Move/rename a file in place (mv in a temp workspace and commit)
pub async fn mv_file(
    remote_repo: &RemoteRepository,
    branch: impl AsRef<str>,
    source_path: impl AsRef<Path>,
    new_path: impl AsRef<Path>,
    commit_body: Option<NewCommitBody>,
) -> Result<CommitResponse, OxenError> {
    let branch = branch.as_ref();
    let source_path = source_path.as_ref();
    let new_path = new_path.as_ref();

    let source_path_str = source_path.to_string_lossy().to_string();
    let new_path_str = new_path.to_string_lossy().to_string();

    let uri = format!("/file/{branch}/{source_path_str}");
    log::debug!("mv_file {uri:?}, new_path {new_path_str:?}");
    let url = api::endpoint::url_from_repo(remote_repo, &uri)?;

    let client = client::new_for_url(&url)?;

    // Build JSON body
    let mut body = serde_json::json!({
        "new_path": new_path_str
    });

    if let Some(commit) = commit_body {
        body["name"] = serde_json::Value::String(commit.author);
        body["email"] = serde_json::Value::String(commit.email);
        body["message"] = serde_json::Value::String(commit.message);
    }

    let req = client
        .patch(&url)
        .header("Content-Type", "application/json")
        .body(body.to_string());

    let res = req.send().await?;
    let body = client::parse_json_body(&url, res).await?;
    let response: CommitResponse = serde_json::from_str(&body)?;
    Ok(response)
}

/// Delete a file in place (rm from a temp workspace and commit)
pub async fn delete_file(
    remote_repo: &RemoteRepository,
    branch: impl AsRef<str>,
    file_path: impl AsRef<Path>,
    commit_body: Option<NewCommitBody>,
) -> Result<CommitResponse, OxenError> {
    let branch = branch.as_ref();
    let file_path = file_path.as_ref();

    let file_path = file_path.to_string_lossy().to_string();

    let uri = format!("/file/{branch}/{file_path}");
    log::debug!("delete_file {uri:?}, file_path {file_path:?}");
    let url = api::endpoint::url_from_repo(remote_repo, &uri)?;

    let client = client::new_for_url(&url)?;
    let mut form = Form::new();

    if let Some(body) = commit_body {
        form = form.text("name", body.author);
        form = form.text("email", body.email);
        form = form.text("message", body.message);
    }

    let req = client.delete(&url).multipart(form);

    let res = req.send().await?;
    let body = client::parse_json_body(&url, res).await?;
    let response: CommitResponse = serde_json::from_str(&body)?;
    Ok(response)
}

#[cfg(test)]
mod tests {

    use bytes::Bytes;

    use crate::constants::DEFAULT_BRANCH_NAME;
    use crate::error::OxenError;
    use crate::model::NewCommitBody;
    use crate::{api, repositories, test, util};
    use std::path::{Path, PathBuf};

    #[tokio::test]
    async fn test_update_file() -> Result<(), OxenError> {
        test::run_remote_repo_test_bounding_box_csv_pushed(|local_repo, remote_repo| async move {
            let branch_name = "main";
            let directory_name = "test_data";
            let file_path = test::test_img_file();
            let commit_body = NewCommitBody {
                author: "Test Author".to_string(),
                email: "test@example.com".to_string(),
                message: "Update file test".to_string(),
            };

            let response = api::client::file::put_file(
                &remote_repo,
                branch_name,
                directory_name,
                &file_path,
                Some("test.jpeg"),
                Some(commit_body),
            )
            .await?;

            assert_eq!(response.status.status_message, "resource_created");

            // Pull changes from remote to local repo
            repositories::pull(&local_repo).await?;

            // Check that the file exists in the local repo after pulling
            let file_path_in_repo = local_repo.path.join(directory_name).join("test.jpeg");
            assert!(file_path_in_repo.exists());

            Ok(remote_repo)
        })
        .await
    }

    #[tokio::test]
    async fn test_update_file_on_empty_repo() -> Result<(), OxenError> {
        test::run_empty_configured_remote_repo_test(|local_repo, remote_repo| async move {
            let branch_name = "main";
            let directory_name = "test_data";
            let file_path = test::test_img_file();
            let commit_body = NewCommitBody {
                author: "Test Author".to_string(),
                email: "test@example.com".to_string(),
                message: "Update file test".to_string(),
            };

            let response = api::client::file::put_file(
                &remote_repo,
                branch_name,
                directory_name,
                &file_path,
                Some("test.jpeg"),
                Some(commit_body),
            )
            .await?;
            assert_eq!(response.status.status_message, "resource_created");

            // Pull changes from remote to local repo
            repositories::pull(&local_repo).await?;
            repositories::checkout(&local_repo, branch_name).await?;

            // // Check that the file exists in the local repo after pulling
            let file_path_in_repo = local_repo.path.join(directory_name).join("test.jpeg");
            assert!(file_path_in_repo.exists());

            Ok(remote_repo)
        })
        .await
    }

    #[tokio::test]
    async fn test_update_file_to_full_path() -> Result<(), OxenError> {
        test::run_remote_repo_test_bounding_box_csv_pushed(|local_repo, remote_repo| async move {
            let branch_name = "main";
            let file_path_on_repo = "test_data/test_full_path.jpeg";
            let file_path = test::test_img_file();
            let commit_body = NewCommitBody {
                author: "Test Author".to_string(),
                email: "test@example.com".to_string(),
                message: "Update file test full path".to_string(),
            };

            let response = api::client::file::put_file_to_path(
                &remote_repo,
                branch_name,
                file_path_on_repo,
                &file_path,
                Some("ignored-name.jpeg"),
                Some(commit_body),
            )
            .await?;

            assert_eq!(response.status.status_message, "resource_created");

            repositories::pull(&local_repo).await?;
            let file_path_in_repo = local_repo.path.join(file_path_on_repo);
            assert!(file_path_in_repo.exists());

            Ok(remote_repo)
        })
        .await
    }

    #[tokio::test]
    async fn test_update_file_to_full_path_on_empty_repo() -> Result<(), OxenError> {
        test::run_empty_configured_remote_repo_test(|local_repo, remote_repo| async move {
            let branch_name = "main";
            let file_path_on_repo = "test_data/test_full_path.jpeg";
            let file_path = test::test_img_file();
            let commit_body = NewCommitBody {
                author: "Test Author".to_string(),
                email: "test@example.com".to_string(),
                message: "Update file test full path".to_string(),
            };

            let response = api::client::file::put_file_to_path(
                &remote_repo,
                branch_name,
                file_path_on_repo,
                &file_path,
                Some("ignored-name.jpeg"),
                Some(commit_body),
            )
            .await?;
            assert_eq!(response.status.status_message, "resource_created");

            repositories::pull(&local_repo).await?;
            repositories::checkout(&local_repo, branch_name).await?;
            let file_path_in_repo = local_repo.path.join(file_path_on_repo);
            assert!(file_path_in_repo.exists());

            Ok(remote_repo)
        })
        .await
    }

    #[tokio::test]
    async fn test_get_file() -> Result<(), OxenError> {
        test::run_remote_repo_test_bounding_box_csv_pushed(|_local_repo, remote_repo| async move {
            let branch_name = "main";
            let file_path = test::test_bounding_box_csv();
            let bytes = api::client::file::get_file(&remote_repo, branch_name, file_path).await;

            assert!(bytes.is_ok());
            assert!(!bytes.unwrap().is_empty());

            Ok(remote_repo)
        })
        .await
    }

    #[tokio::test]
    async fn test_delete_file() -> Result<(), OxenError> {
        test::run_remote_repo_test_bounding_box_csv_pushed(|local_repo, remote_repo| async move {
            let prev_commits = repositories::commits::list_all(&local_repo)?;

            let branch_name = "main";
            let file_path = test::test_bounding_box_csv();

            let commit_body = NewCommitBody {
                author: "Test Author".to_string(),
                email: "test@example.com".to_string(),
                message: "remove file".to_string(),
            };

            // Delete the file on the remote repo
            let _commit_response = api::client::file::delete_file(
                &remote_repo,
                &branch_name,
                &file_path,
                Some(commit_body),
            )
            .await?;

            // Pull the change
            repositories::pull(&local_repo).await?;

            // Assert the commit was made and the file is removed
            assert!(!local_repo.path.join(&file_path).exists());

            /*
            let commit = commit_response.commit;
            let deleted_file_node =
                repositories::tree::get_node_by_path(&local_repo, &commit, &file_path)?;
            assert!(deleted_file_node.is_none());
            */

            let new_commits = repositories::commits::list_all(&local_repo)?;
            assert_eq!(new_commits.len(), prev_commits.len() + 1);

            Ok(remote_repo)
        })
        .await
    }

    #[tokio::test]
    async fn test_delete_file_after_upload() -> Result<(), OxenError> {
        test::run_training_data_fully_sync_remote(|local_repo, remote_repo| async move {
            let branch_name = "main";

            // Find a file (not a directory) to delete
            // Files in train directory: dog_1.jpg, dog_2.jpg, dog_3.jpg, dog_4.jpg, cat_1.jpg, cat_2.jpg, cat_3.jpg
            let file_to_delete = "train/dog_1.jpg";

            // Verify the file exists before deletion
            let file_path = local_repo.path.join(file_to_delete);
            assert!(file_path.exists(), "File should exist before deletion");

            // Delete the file
            let delete_commit_body = NewCommitBody {
                author: "Test Author".to_string(),
                email: "test@example.com".to_string(),
                message: "Delete existing file from training data".to_string(),
            };

            let delete_response = api::client::file::delete_file(
                &remote_repo,
                branch_name,
                &file_to_delete,
                Some(delete_commit_body),
            )
            .await?;

            assert_eq!(delete_response.status.status_message, "resource_deleted");
            assert!(
                delete_response
                    .commit
                    .message
                    .contains("Delete existing file from training data")
            );

            // Pull the deletion
            repositories::pull(&local_repo).await?;

            // Verify the file is deleted
            assert!(!file_path.exists(), "File should be deleted after deletion");

            Ok(remote_repo)
        })
        .await
    }

    #[tokio::test]
    async fn test_mv_file() -> Result<(), OxenError> {
        test::run_training_data_fully_sync_remote(|local_repo, remote_repo| async move {
            let branch_name = "main";

            // File to move
            let source_path = "train/dog_1.jpg";
            let new_path = "renamed/images/dog_moved.jpg";

            // Verify the file exists before moving
            let file_path = local_repo.path.join(source_path);
            assert!(file_path.exists(), "Source file should exist before move");

            // Move the file
            let mv_commit_body = NewCommitBody {
                author: "Test Author".to_string(),
                email: "test@example.com".to_string(),
                message: "Move file to new location".to_string(),
            };

            let mv_response = api::client::file::mv_file(
                &remote_repo,
                branch_name,
                source_path,
                new_path,
                Some(mv_commit_body),
            )
            .await?;

            assert_eq!(mv_response.status.status_message, "resource_updated");
            assert!(
                mv_response
                    .commit
                    .message
                    .contains("Move file to new location")
            );

            // Pull the changes
            repositories::pull(&local_repo).await?;

            // Verify the file is at the new location
            let new_file_path = local_repo.path.join(new_path);
            assert!(
                new_file_path.exists(),
                "File should exist at new location after move"
            );

            // Verify the file is no longer at the original location
            assert!(
                !file_path.exists(),
                "File should not exist at original location after move"
            );

            Ok(remote_repo)
        })
        .await
    }

    #[tokio::test]
    async fn test_get_file_with_workspace() -> Result<(), OxenError> {
        test::run_remote_repo_test_bounding_box_csv_pushed(|local_repo, remote_repo| async move {
            let base_dir = "annotations";
            let data_set = "train";
            let file_name = "file.txt";
            let workspace_id = "test_workspace_id";

            let file_path = PathBuf::from(base_dir)
                .join(data_set)
                .join(file_name)
                .to_string_lossy()
                .into_owned();

            let directory_name = PathBuf::from(base_dir)
                .join(data_set)
                .to_string_lossy()
                .into_owned();

            let workspace =
                api::client::workspaces::create(&remote_repo, DEFAULT_BRANCH_NAME, &workspace_id)
                    .await?;
            assert_eq!(workspace.id, workspace_id);

            let full_path = local_repo.path.join(&file_path);
            util::fs::file_create(&full_path)?;
            util::fs::write(&full_path, b"test content")?;

            let _result = api::client::workspaces::files::upload_single_file(
                &remote_repo,
                &workspace.id,
                directory_name,
                &full_path,
            )
            .await;

            let bytes = api::client::file::get_file(&remote_repo, workspace_id, file_path).await;

            assert!(bytes.is_ok());
            assert!(!bytes.as_ref().unwrap().is_empty());
            assert_eq!(bytes.unwrap(), Bytes::from_static(b"test content"));

            Ok(remote_repo)
        })
        .await
    }

    #[tokio::test]
    #[cfg(feature = "ffmpeg")]
    async fn test_upload_video_and_get_thumbnail() -> Result<(), OxenError> {
        test::run_empty_configured_remote_repo_test(|_local_repo, remote_repo| async move {
            let branch_name = DEFAULT_BRANCH_NAME;
            let directory_name = "videos";
            let video_file = test::test_video_file_with_name("basketball.mp4");

            // Verify the test video file exists
            assert!(
                video_file.exists(),
                "Test video file should exist at {video_file:?}"
            );

            let commit_body = NewCommitBody {
                author: "Test Author".to_string(),
                email: "test@example.com".to_string(),
                message: "Upload test video".to_string(),
            };

            // Upload the video file
            let response = api::client::file::put_file(
                &remote_repo,
                branch_name,
                directory_name,
                &video_file,
                Some("basketball.mp4"),
                Some(commit_body),
            )
            .await?;

            assert_eq!(response.status.status_message, "resource_created");

            // Download the thumbnail with default settings
            let thumbnail_path = format!("{directory_name}/basketball.mp4");
            let thumbnail_bytes = api::client::file::get_file_thumbnail(
                &remote_repo,
                branch_name,
                thumbnail_path.as_str(),
                None,
                None,
                None,
            )
            .await?;

            // Verify thumbnail is not empty
            assert!(!thumbnail_bytes.is_empty(), "Thumbnail should not be empty");

            // Verify it's a JPEG (JPEG files start with FF D8 FF)
            assert!(
                thumbnail_bytes.len() >= 3,
                "Thumbnail should be at least 3 bytes"
            );
            assert_eq!(
                thumbnail_bytes[0], 0xFF,
                "Thumbnail should start with JPEG magic bytes"
            );
            assert_eq!(
                thumbnail_bytes[1], 0xD8,
                "Thumbnail should start with JPEG magic bytes"
            );
            assert_eq!(
                thumbnail_bytes[2], 0xFF,
                "Thumbnail should start with JPEG magic bytes"
            );

            // Test with custom dimensions
            let thumbnail_bytes_custom = api::client::file::get_file_thumbnail(
                &remote_repo,
                branch_name,
                thumbnail_path.as_str(),
                Some(640),
                Some(480),
                Some(0.5),
            )
            .await?;

            assert!(
                !thumbnail_bytes_custom.is_empty(),
                "Custom thumbnail should not be empty"
            );
            assert_eq!(
                thumbnail_bytes_custom[0], 0xFF,
                "Custom thumbnail should be a JPEG"
            );
            assert_eq!(
                thumbnail_bytes_custom[1], 0xD8,
                "Custom thumbnail should be a JPEG"
            );

            Ok(remote_repo)
        })
        .await
    }

    // Test that downloading a file from a deleted directory returns an error
    #[tokio::test]
    async fn test_rm_directory() -> Result<(), OxenError> {
        test::run_remote_repo_test_bounding_box_csv_pushed(|_local_repo, remote_repo| async move {
            let annotations_d = Path::new("annotations");
            let train_d = annotations_d.join("train");
            let file = train_d.join("bounding_box.csv");

            // Remove the committed directory "annotations/train"
            let c = api::client::file::delete_file(
                &remote_repo,
                DEFAULT_BRANCH_NAME,
                &train_d,
                Some(NewCommitBody {
                    message: "delete train dir".into(),
                    author: "author".into(),
                    email: "ox@oxen.ai".into(),
                }),
            )
            .await?;

            println!("deleted {} as commit {}", train_d.display(), c.commit.id);

            let contents =
                api::client::file::get_file(&remote_repo, DEFAULT_BRANCH_NAME, &file).await;
            assert!(
                contents.is_err(),
                "Fetching deleted file should be an error, but got: {:?}",
                contents
            );

            Ok(remote_repo)
        })
        .await
    }
}