Skip to content

Commit afa0631

Browse files
Merge pull request #280 from fairagro/remove_init_arc
Init changes
2 parents 6e1e8d7 + 0280d30 commit afa0631

13 files changed

Lines changed: 76 additions & 300 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
## 🚀 Features
33
- Updated the underlying CWL libraries to our [`commonwl`](https://github.com/fairagro/commonwl) library #236
44
- Removed `annotate` command due to lack of usage
5+
- Removed `init` Option `-a` which could be used to create ARCs - from a long term perspective the ARC spec may change - if we are not able to provide updates everytime this feature obsoletes anyway
56

67
## 🐛 Bugfixes
78
- ramping up runner conformance from 223/378 to 376/378

Cargo.lock

Lines changed: 2 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ anyhow = "1.0.102"
2929
commonwl = { version = "0.8.1", features = ["engine"] }
3030
colored = "3.1.1"
3131
dialoguer = { version = "0.12.0", features = ["fuzzy-select"] }
32-
dircpy = "0.3.20"
32+
dircpy = "0.3.19"
33+
dunce = "1.0.5"
3334
fancy-regex = "0.18.0"
3435
git2 = { version = "0.21.0", features = ["vendored-openssl"] }
3536
keyring = { version = "3.6.3", features = [

README.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -157,26 +157,6 @@ Most commands need the context of a Git repo to work. Project initialization can
157157
```bash
158158
s4n init -p <FOLDER/PROJECT NAME>
159159
```
160-
Besides the minimal project structure, the creation of an ["Annotated Research Context"](https://arc-rdm.org/) or ARC is also possible.
161-
```bash
162-
s4n init -a -p <FOLDER/PROJECT NAME>
163-
```
164-
165-
> [!IMPORTANT]
166-
> The commands have changed in v1.0.0 (**Breaking Change**). The mapping is as follows:
167-
> | Old Command | New Command |
168-
> |---------------------------|------------------------|
169-
> | s4n tool create | s4n create |
170-
> | s4n tool list | s4n list |
171-
> | s4n tool remove | s4n remove |
172-
> | s4n workflow create | s4n create --name (optional!)|
173-
> | s4n workflow list | s4n list |
174-
> | s4n workflow remove | s4n remove |
175-
> | s4n workflow status | s4n list [WORKFLOW_NAME]|
176-
> | s4n workflow connect | s4n connect |
177-
> | s4n workflow disconnect | s4n disconnect |
178-
> | s4n workflow visualize | s4n visualize |
179-
> | s4n workflow save | s4n save |
180160

181161
### Creation of CWL CommandLineTools
182162
To create [CWL](https://www.commonwl.org/) CommandLineTools which can be combined to workflows later a prefix command can be used. `s4n create` will execute any given command and creates a CWL CommandLineTool accordingly.

docs/src/content/docs/reference/init.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ The `s4n init` command is used to initialize a SciWIn project. It will create a
1515
1616
Options:
1717
-p, --project <PROJECT> Name of the project
18-
-a, --arc Option to create basic arc folder structure
1918
-h, --help Print help
2019
```

packages/cli/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ clap_complete = "4.5.61"
3535
ignore = "0.4.23"
3636
prettytable-rs = "0.10.0"
3737

38+
dunce.workspace = true
39+
3840
syntect = { version = "5.2.0", default-features = false, features = [
3941
"regex-fancy",
4042
"parsing",

packages/cli/src/commands/init.rs

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
use anyhow::Context;
22
use clap::Args;
33
use log::info;
4-
use std::{env, path::PathBuf};
4+
use std::path::PathBuf;
55

66
#[derive(Args, Debug, Default)]
77
pub struct InitArgs {
88
#[arg(short = 'p', long = "project", help = "Name of the project")]
99
pub project: Option<String>,
10-
#[arg(
11-
short = 'a',
12-
long = "arc",
13-
help = "Option to create basic arc folder structure"
14-
)]
15-
pub arc: bool,
1610
}
1711

1812
pub fn handle_init_command(args: &InitArgs) -> anyhow::Result<()> {
1913
let base_dir = match &args.project {
2014
Some(folder) => PathBuf::from(folder),
21-
None => env::current_dir()?,
15+
None => PathBuf::new(),
2216
};
2317

24-
s4n_core::project::initialize_project(&base_dir, args.arc)
18+
s4n_core::project::initialize_project(&base_dir)
2519
.inspect_err(|_| {
2620
let _ = s4n_core::project::git_cleanup(args.project.clone());
2721
})
@@ -34,66 +28,36 @@ pub fn handle_init_command(args: &InitArgs) -> anyhow::Result<()> {
3428
mod tests {
3529
use super::*;
3630
use serial_test::serial;
31+
use std::env;
3732
use tempfile::tempdir;
3833
use test_utils::check_git_user;
3934

4035
#[test]
4136
#[serial]
42-
fn test_init_s4n_without_folder_with_arc() {
43-
//create a temp dir
37+
fn test_init_s4n_without_folder() {
4438
let temp_dir = tempdir().expect("Failed to create a temporary directory");
39+
let cwd = env::current_dir().unwrap();
40+
4541
eprintln!("Temporary directory: {:?}", temp_dir.path());
4642
check_git_user().unwrap();
4743

48-
// Change current dir to the temporary directory to not create workflow folders etc in sciwin-client dir
4944
env::set_current_dir(temp_dir.path()).unwrap();
5045
eprintln!(
5146
"Current directory changed to: {}",
5247
env::current_dir().unwrap().display()
5348
);
5449

55-
// test method without folder name and do not create arc folders
5650
let folder_name: Option<String> = None;
57-
let arc = true;
5851

5952
let result = handle_init_command(&InitArgs {
6053
project: folder_name,
61-
arc,
6254
});
6355

64-
// Assert results is ok and folders exist/ do not exist
6556
assert!(result.is_ok());
6657

6758
assert!(PathBuf::from("workflows").exists());
6859
assert!(PathBuf::from(".git").exists());
69-
assert!(PathBuf::from("assays").exists());
70-
assert!(PathBuf::from("studies").exists());
71-
assert!(PathBuf::from("runs").exists());
72-
}
73-
74-
#[test]
75-
#[serial]
76-
fn test_init_s4n_with_arc() {
77-
let temp_dir = tempdir().unwrap();
78-
check_git_user().unwrap();
79-
let arc = true;
80-
81-
let base_folder = Some(temp_dir.path().to_str().unwrap().to_string());
82-
83-
//call method with temp dir
84-
let result = handle_init_command(&InitArgs {
85-
project: base_folder,
86-
arc,
87-
});
88-
89-
assert!(result.is_ok(), "Expected successful initialization");
90-
91-
//check if directories were created
92-
let expected_dirs = vec!["workflows", "assays", "studies", "runs"];
9360

94-
for dir in &expected_dirs {
95-
let full_path = PathBuf::from(temp_dir.path()).join(dir);
96-
assert!(full_path.exists(), "Directory {dir} does not exist");
97-
}
61+
env::set_current_dir(cwd).unwrap();
9862
}
9963
}

packages/cli/tests/doc_tests.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ use test_utils::{check_git_user, setup_python};
1212
fn setup() -> (PathBuf, TempDir) {
1313
let dir = tempdir().unwrap();
1414

15-
//copy docs dit to tmp
15+
//copy docs dir to tmp
1616
let test_folder = "../../testdata/docs";
1717
copy_dir(test_folder, dir.path()).unwrap();
1818

1919
let current = env::current_dir().unwrap();
20-
env::set_current_dir(dir.path()).unwrap();
20+
let canonicalized = dunce::canonicalize(dir.path()).unwrap();
21+
env::set_current_dir(&canonicalized).unwrap();
2122

2223
//init
2324
check_git_user().unwrap();
24-
initialize_project(dir.path(), false).expect("Could not init s4n");
25+
initialize_project("").expect("Could not init s4n");
2526

2627
(current, dir)
2728
}
@@ -499,7 +500,7 @@ pub async fn test_example_project() {
499500
check_git_user().unwrap();
500501

501502
//init project
502-
initialize_project(dir.path(), false).expect("Could not init s4n");
503+
initialize_project("").expect("Could not init s4n");
503504

504505
//create calculation tool
505506
create_tool(&CreateArgs {

packages/cli/tests/workflow_integration_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn test_remove_workflow() {
4747
let current = env::current_dir().unwrap();
4848
env::set_current_dir(dir.path()).unwrap();
4949

50-
initialize_project(dir.path(), false).unwrap();
50+
initialize_project("").unwrap();
5151
create_workflow(&CreateArgs {
5252
name: Some("test".to_string()),
5353
..Default::default()
@@ -78,7 +78,7 @@ pub fn test_workflow() -> Result<(), Box<dyn std::error::Error>> {
7878
let current = env::current_dir().unwrap();
7979

8080
env::set_current_dir(dir.path()).unwrap();
81-
initialize_project(dir.path(), false).unwrap();
81+
initialize_project("").unwrap();
8282

8383
create_and_write_file("workflows/calculation/calculation.cwl", CALCULATION_FILE).unwrap();
8484
create_and_write_file("workflows/plot/plot.cwl", PLOT_FILE).unwrap();
@@ -183,7 +183,7 @@ pub fn test_workflow_optional_flags() -> Result<(), Box<dyn std::error::Error>>
183183
let current = env::current_dir().unwrap();
184184

185185
env::set_current_dir(dir.path()).unwrap();
186-
initialize_project(dir.path(), false).unwrap();
186+
initialize_project("").unwrap();
187187

188188
create_and_write_file("workflows/calculation/calculation.cwl", CALCULATION_FILE).unwrap();
189189
create_and_write_file("workflows/plot/plot.cwl", PLOT_FILE).unwrap();

packages/core/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ semver = { version = "1.0.26", features = ["serde"] }
2525
shlex = "2.0.1"
2626
slugify = "0.1.0"
2727
smart-default = "0.7.1"
28+
dunce.workspace = true
2829
tokio.workspace = true
2930
tokio-util.workspace = true
3031

3132
[dev-dependencies]
32-
calamine = "0.35.0"
33-
3433
test_utils = { workspace = true }
3534
rstest = { workspace = true }
3635
serial_test = { workspace = true }

0 commit comments

Comments
 (0)