Skip to content

Commit

Permalink
Merge pull request #242 from nfdi4plants/v2.0.0
Browse files Browse the repository at this point in the history
Update ARCtrl dependency to v2.0.0
  • Loading branch information
HLWeil authored Jul 21, 2024
2 parents f17aa01 + 02bdae8 commit 823aca1
Show file tree
Hide file tree
Showing 23 changed files with 598 additions and 564 deletions.
32 changes: 20 additions & 12 deletions src/ArcCommander/APIs/ArcAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ open ArcCommander
open ArcCommander.CLIArguments

open ARCtrl
open ARCtrl.Json
open ARCtrl.NET
open ARCtrl.ISA

[<AutoOpen>]
module ARCExtensions =
Expand All @@ -31,14 +31,23 @@ module API =

module ARC =

open ARCtrl.Process.Conversion

let getProcesses (arc : ARC) =
arc.ISA.Value.ToInvestigation().Studies
|> Option.defaultValue [] |> List.collect (fun s ->
s.Assays
|> Option.defaultValue [] |> List.collect (fun a ->
a.ProcessSequence |> Option.defaultValue []
)
)
match arc.ISA with
| Some inv ->

let studyProcs =
inv.Studies
|> Seq.collect (fun s -> s.GetProcesses())
let assayProcs =
inv.Assays
|> Seq.collect (fun a -> a.GetProcesses())
Seq.append studyProcs assayProcs
|> Seq.toList

| None -> []



/// ArcCommander API functions that get executed by top level subcommand verbs.
Expand Down Expand Up @@ -159,12 +168,11 @@ module ArcAPI =
let arc = ARC.load workDir

let output =
if arcArgs.ContainsFlag ProcessSequence then
if arcArgs.ContainsFlag ArcExportArgs.ProcessSequence then
API.ARC.getProcesses arc
|> ARCtrl.ISA.Json.ProcessSequence.toJsonString
|> ARCtrl.Json.ProcessSequence.toISAJsonString(2)
else
arc.ISA.Value
|> ARCtrl.ISA.Json.ArcInvestigation.toJsonString
arc.ISA.Value.ToISAJsonString(2)

match arcArgs.TryGetFieldValue Output with
| Some p ->
Expand Down
191 changes: 95 additions & 96 deletions src/ArcCommander/APIs/AssayAPI.fs

Large diffs are not rendered by default.

268 changes: 153 additions & 115 deletions src/ArcCommander/APIs/InvestigationAPI.fs

Large diffs are not rendered by default.

443 changes: 216 additions & 227 deletions src/ArcCommander/APIs/StudyAPI.fs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/ArcCommander/ArcCommander.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@
<!--References-->
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="8.0.101" />
<PackageReference Include="ARCtrl.NET" Version="1.0.4" />
<PackageReference Include="ARCtrl.NET" Version="2.0.0-beta.1" />
<PackageReference Include="Argu" Version="6.1.5" />
<PackageReference Include="Fake.IO.FileSystem" Version="6.0.0" />
<PackageReference Include="Fake.Tools.Git" Version="6.0.0" />
<PackageReference Include="FSharp.Data" Version="5.0.2" />
<PackageReference Include="FsSpreadsheet" Version="5.1.2" />
<PackageReference Include="FsSpreadsheet" Version="6.2.0" />
<PackageReference Include="IdentityModel.OidcClient" Version="5.2.1" />
<PackageReference Include="ini-parser-netstandard" Version="2.5.2" />
<PackageReference Include="Giraffe" Version="6.0.0" />
Expand Down
6 changes: 3 additions & 3 deletions src/ArcCommander/ArcConfiguration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,15 @@ module ARCExtensions =

open Contract
open FsSpreadsheet
open FsSpreadsheet.ExcelIO
open FsSpreadsheet.Net

let myWrite basePath (c : Contract) =
let log = Logging.createLogger("WriteContractHandler")
match c.DTO with
| Some (DTO.Spreadsheet wb) ->
let path = System.IO.Path.Combine(basePath, c.Path)
Path.ensureDirectory path
FsWorkbook.toFile path (wb :?> FsWorkbook)
FsWorkbook.toXlsxFile path (wb :?> FsWorkbook)
| Some (DTO.Text t) ->
let path = System.IO.Path.Combine(basePath, c.Path)
Path.ensureDirectory path
Expand All @@ -458,7 +458,7 @@ module ARCExtensions =
type ARC with

member this.Write(arcPath) =
this.GetWriteContracts(false)
this.GetWriteContracts()
|> Array.iter (myWrite arcPath)

static member load(config : ArcConfiguration) =
Expand Down
12 changes: 6 additions & 6 deletions src/ArcCommander/ArgumentProcessing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -407,19 +407,19 @@ module ArgumentProcessing =
|> ArcParseResults

/// Serializes the output of a writer and converts it into a string.
let serializeXSLXWriterOutput (writeF : 'A -> seq<ARCtrl.ISA.Spreadsheet.SparseRow>) (inp : 'A) =
let serializeXSLXWriterOutput (writeF : 'A -> seq<ARCtrl.Spreadsheet.SparseRow>) (inp : 'A) =
writeF inp
|> Seq.map (fun r ->
sprintf "%s:%s"
(ARCtrl.ISA.Spreadsheet.SparseRow.tryGetValueAt 0 r |> Option.get |> fun s -> s.TrimStart())
(ARCtrl.ISA.Spreadsheet.SparseRow.tryGetValueAt 1 r |> Option.get)
(ARCtrl.Spreadsheet.SparseRow.tryGetValueAt 0 r |> Option.get |> fun s -> s.TrimStart())
(ARCtrl.Spreadsheet.SparseRow.tryGetValueAt 1 r |> Option.get)
)
|> Seq.reduce (fun a b -> a + "\n" + b)

/// Opens a textprompt containing the serialized input item. Returns item updated with the deserialized user input.
let createIsaItemQuery editorPath
(writeF : 'A -> seq<ARCtrl.ISA.Spreadsheet.SparseRow>)
(readF : System.Collections.Generic.IEnumerator<ARCtrl.ISA.Spreadsheet.SparseRow> -> 'A)
(writeF : 'A -> seq<ARCtrl.Spreadsheet.SparseRow>)
(readF : System.Collections.Generic.IEnumerator<ARCtrl.Spreadsheet.SparseRow> -> 'A)
(isaItem : 'A) =

let log = Logging.createLogger "ArgumentProcessingPromptCreateIsaItemQueryLog"
Expand All @@ -441,7 +441,7 @@ module ArgumentProcessing =
Some (
match splitAtFirst ':' x with
| k, Field v ->
ARCtrl.ISA.Spreadsheet.SparseRow.fromValues [k;v]
ARCtrl.Spreadsheet.SparseRow.fromValues [k;v]
| _ -> log.Fatal("File was corrupted in Editor."); raise (Exception(""))
)
)
Expand Down
12 changes: 6 additions & 6 deletions src/ArcCommander/CLIArguments/ArcArgs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type ArcInitArgs =
| RepositoryAddress _ -> "Git repository address"
| EditorPath _ -> "The path leading to the editor used for text prompts (Default in Windows is Notepad; Default in Unix systems is Nano)"
| GitLFSByteThreshold _ -> "The git LFS file size threshold in bytes. File larger than this threshold will be tracked by git LFS (Default Value is 150000000 Bytes ~ 150 MB)."
| Gitignore _ -> "Use this flag if you want a default .gitignore to be added to the initialized repo"
| Gitignore -> "Use this flag if you want a default .gitignore to be added to the initialized repo"

type ArcExportArgs =

Expand All @@ -48,7 +48,7 @@ type ArcExportArgs =
member this.Usage =
match this with
| Output _ -> "Path to which the json should be exported. Only written to the cli output if no path given"
| ProcessSequence _ -> "If this flag is set, the return value of this arc will be its list of all its processes"
| ProcessSequence -> "If this flag is set, the return value of this arc will be its list of all its processes"


/// TO-DO: Argumente anpassen
Expand All @@ -66,8 +66,8 @@ type ArcSyncArgs =
| RepositoryAddress _ -> "Git remote address with which to sync the ARC. If no address is either given here or set previously when initing or getting the ARC, changes are only committed but not synced."
| CommitMessage _ -> "Descriptive title for the changes made (e.g. add new assay). If none is given, default commit message is used."
| Branch _ -> "Name of the branch to which the changes should be pushed. If none is given, defaults to \"main\""
| NoLFS _ -> "Does download only the pointers of LFS files, not the file content itself. Ideal for when you're only interested in the experimental metadata, not the data itself."
| Force _ -> "When a remote is set, but does not exist online, tries to create it."
| NoLFS -> "Does download only the pointers of LFS files, not the file content itself. Ideal for when you're only interested in the experimental metadata, not the data itself."
| Force -> "When a remote is set, but does not exist online, tries to create it."

/// TO-DO: Argumente anpassen
type ArcGetArgs =
Expand All @@ -81,8 +81,8 @@ type ArcGetArgs =
match this with
| RepositoryAddress _ -> "Git remote address from which to pull the ARC"
| BranchName _ -> "Branch of the remote address which should be used. If none is given, uses \"main\""
| NoLFS _ -> "Does download only the pointers of LFS files, not the file content itself. Ideal for when you're only interested in the experimental metadata, not the data itself."
| Merge _ -> "Merges the repository into the current folder. Fails, if the current folder isn't empty."
| NoLFS -> "Does download only the pointers of LFS files, not the file content itself. Ideal for when you're only interested in the experimental metadata, not the data itself."
| Merge -> "Merges the repository into the current folder. Fails, if the current folder isn't empty."

type ArcServerArgs =
| [<Unique>][<AltCommandLine("-p")>] Port of port_address : string
Expand Down
10 changes: 5 additions & 5 deletions src/ArcCommander/CLIArguments/AssayArgs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ type AssayUpdateArgs =
| TechnologyTypeTermAccessionNumber _ -> "The accession number from the Term Source associated with the selected term."
| TechnologyTypeTermSourceREF _ -> "Identifies the controlled vocabulary or ontology that this term comes from. The Source REF has to match one of the Term Source Names declared in the Ontology Source Reference section."
| TechnologyPlatform _ -> "Manufacturer and platform name, e.g. Bruker AVANCE"
| ReplaceWithEmptyValues _ -> "This flag can be used to delete fields from the assay. If this flag is not set, only these fields for which a value was given will be updated."
| AddIfMissing _ -> "If this flag is set, a new assay will be registered with the given parameters, if it did not previously exist"
| ReplaceWithEmptyValues -> "This flag can be used to delete fields from the assay. If this flag is not set, only these fields for which a value was given will be updated."
| AddIfMissing -> "If this flag is set, a new assay will be registered with the given parameters, if it did not previously exist"

/// CLI arguments for interactively editing existing assay metadata.
type AssayEditArgs =
Expand Down Expand Up @@ -143,7 +143,7 @@ type AssayExportArgs =
match this with
| AssayIdentifier _ -> "Identifier of the assay of interest"
| Output _ -> "Path to which the json should be exported. Only written to the cli output if no path given"
| ProcessSequence _ -> "If this flag is set, the return value of this assay will be its list of processes"
| ProcessSequence -> "If this flag is set, the return value of this assay will be its list of processes"

/// CLI arguments for assay contacts.
module AssayContacts =
Expand Down Expand Up @@ -182,8 +182,8 @@ module AssayContacts =
| Roles _ -> "Term to classify the role(s) performed by this person in the context of the assay, which means that the roles reported here do not need to correspond to roles held withing their affiliated organization. Multiple annotations or values attached to one person can be provided by using a semicolon (“;”) Unicode (U0003+B) as a separator (e.g.: submitter;funder;sponsor). The term can be free text or from, for example, a controlled vocabulary or an ontology. If the latter source is used, the Term Accession Number (TAN) and Term Source REF fields below are required."
| RolesTermAccessionNumber _ -> "The accession number from the Term Source associated with the selected term"
| RolesTermSourceREF _ -> "Identifies the controlled vocabulary or ontology that this term comes from. The Source REF has to match one of the Term Source Names declared in the Ontology Source Reference section."
| ReplaceWithEmptyValues _ -> "This flag can be used to delete fields from the assay. If this flag is not set, only these fields for which a value was given will be updated."
| AddIfMissing _ -> "If this flag is set, a new person will be registered with the given parameters, if it did not previously exist"
| ReplaceWithEmptyValues -> "This flag can be used to delete fields from the assay. If this flag is not set, only these fields for which a value was given will be updated."
| AddIfMissing -> "If this flag is set, a new person will be registered with the given parameters, if it did not previously exist"

/// CLI arguments for interactively editing existing person metadata.
type PersonEditArgs =
Expand Down
20 changes: 10 additions & 10 deletions src/ArcCommander/CLIArguments/ConfigurationArgs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ type ConfigurationListArgs =
interface IArgParserTemplate with
member this.Usage =
match this with
| Local _ -> "Lists the local settings for this Arc"
| Global _ -> "Lists the global settings of the ArcCommander"
| Local -> "Lists the local settings for this Arc"
| Global -> "Lists the global settings of the ArcCommander"

/// CLI arguments for configuration editing
type ConfigurationEditArgs =
Expand All @@ -20,8 +20,8 @@ type ConfigurationEditArgs =
interface IArgParserTemplate with
member this.Usage =
match this with
| Local _ -> "Edit the local settings for this ARC"
| Global _ -> "Edit the global settings of the ArcCommander"
| Local -> "Edit the local settings for this ARC"
| Global -> "Edit the global settings of the ArcCommander"

/// CLI arguments for setting a configuration setting
type ConfigurationSetArgs =
Expand All @@ -33,8 +33,8 @@ type ConfigurationSetArgs =
interface IArgParserTemplate with
member this.Usage =
match this with
| Local _ -> "Set the the value of the name locally for this ARC"
| Global _ -> "Set the the value of the name globally for the ArcCommander"
| Local -> "Set the the value of the name locally for this ARC"
| Global -> "Set the the value of the name globally for the ArcCommander"
| Name _ -> "The name of the setting in 'Section.Key' format"
| Value _ -> "The new value of the setting"

Expand All @@ -47,8 +47,8 @@ type ConfigurationUnsetArgs =
interface IArgParserTemplate with
member this.Usage =
match this with
| Local _ -> "Unset the the value of the name locally for this ARC"
| Global _ -> "Unset the the value of the name globally for the ArcCommander"
| Local -> "Unset the the value of the name locally for this ARC"
| Global -> "Unset the the value of the name globally for the ArcCommander"
| Name _ -> "The name of the setting in 'Section.Key' format"

/// CLI arguments for transferring the git user metadata from the arc config to the git config
Expand All @@ -61,7 +61,7 @@ type ConfigurationSetGitUserArgs =
interface IArgParserTemplate with
member this.Usage =
match this with
| Local _ -> "Set the git user metadata locally for this arc repository"
| Global _ -> "Set the git user metadata globally for the git installation"
| Local -> "Set the git user metadata locally for this arc repository"
| Global -> "Set the git user metadata globally for the git installation"
| Name _ -> "The name of the user"
| Email _ -> "The e-mail of the user"
10 changes: 5 additions & 5 deletions src/ArcCommander/CLIArguments/InvestigationArgs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type InvestigationUpdateArgs =
| Description _ -> "A textual description of the investigation"
| SubmissionDate _ -> "The date on which the investigation was reported to the repository"
| PublicReleaseDate _ -> "The date on which the investigation was released publicly"
| ReplaceWithEmptyValues _ -> "This flag can be used to delete fields from the investigation. If this flag is not set, only these fields for which a value was given will be updated."
| ReplaceWithEmptyValues -> "This flag can be used to delete fields from the investigation. If this flag is not set, only these fields for which a value was given will be updated."


///// CLI arguments for deleting the arc's investigation file (danger zone!)
Expand Down Expand Up @@ -90,8 +90,8 @@ module InvestigationContacts =
| Roles _ -> "Term to classify the role(s) performed by this person in the context of the investigation, which means that the roles reported here do not need to correspond to roles held withing their affiliated organization. Multiple annotations or values attached to one person can be provided by using a semicolon (“;”) Unicode (U0003+B) as a separator (e.g.: submitter;funder;sponsor). The term can be free text or from, for example, a controlled vocabulary or an ontology. If the latter source is used the Term Accession Number (TAN) and Term Source REF fields below are required."
| RolesTermAccessionNumber _ -> "The accession number from the Term Source associated with the selected term. If multiple role terms are defined, multiple accession numbers have to be defined accordingly, separated by a semicolon (“;”)."
| RolesTermSourceREF _ -> "Identifies the controlled vocabulary or ontology that this term comes from. The Source REF has to match one of the Term Source Names declared in the Ontology Source Reference section. If multiple role terms are defined, multiple source REFs have to be defined accordingly, separated by a semicolon (“;”)."
| ReplaceWithEmptyValues _ -> "This flag can be used to delete fields from the person. If this flag is not set, only these fields for which a value was given will be updated."
| AddIfMissing _ -> "If this flag is set, a new person will be registered with the given parameters, if it did not previously exist"
| ReplaceWithEmptyValues -> "This flag can be used to delete fields from the person. If this flag is not set, only these fields for which a value was given will be updated."
| AddIfMissing -> "If this flag is set, a new person will be registered with the given parameters, if it did not previously exist"

/// CLI arguments for interactively editing existing person metadata
type PersonEditArgs =
Expand Down Expand Up @@ -171,8 +171,8 @@ module InvestigationPublications =
| Status _ -> "A term describing the status of that publication (i.e. submitted, in preparation, published)"
| StatusTermAccessionNumber _ -> "The accession number from the Term Source associated with the selected term"
| StatusTermSourceREF _ -> "Identifies the controlled vocabulary or ontology that this term comes from. The Source REF has to match one the Term Source Name declared in the in the Ontology Source Reference section."
| ReplaceWithEmptyValues _ -> "This flag can be used to delete fields from the publication. If this flag is not set, only these fields for which a value was given will be updated."
| AddIfMissing _ -> "If this flag is set, a new publication will be registered with the given parameters, if it did not previously exist"
| ReplaceWithEmptyValues -> "This flag can be used to delete fields from the publication. If this flag is not set, only these fields for which a value was given will be updated."
| AddIfMissing -> "If this flag is set, a new publication will be registered with the given parameters, if it did not previously exist"


/// CLI arguments for interactively editing existing publication metadata
Expand Down
Loading

0 comments on commit 823aca1

Please sign in to comment.