Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes and enhancements #223

Merged
merged 3 commits into from
Oct 11, 2023
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
2 changes: 1 addition & 1 deletion src/ArcCommander/APIs/ArcAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module ArcAPI =
let branch = arcArgs.TryGetFieldValue ArcInitArgs.Branch |> Option.defaultValue GitHelper.defaultBranch
let repositoryAddress = arcArgs.TryGetFieldValue ArcInitArgs.RepositoryAddress
let identifier =
arcArgs.TryGetFieldValue ArcInitArgs.Identifier
arcArgs.TryGetFieldValue ArcInitArgs.InvestigationIdentifier
|> Option.defaultValue (DirectoryInfo(workDir).Name)

log.Trace("Create Directory")
Expand Down
4 changes: 2 additions & 2 deletions src/ArcCommander/APIs/ConfigurationAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ module ConfigurationAPI =
log.Trace("Retrieved user name from given argument.")
Some name
| None ->
log.Trace("Could not retrieve user name from argument. Try to retrieve it from ARC config.")
log.Info("Could not retrieve user name from argument. Try to retrieve it from ARC config.")
GeneralConfiguration.tryGetGitName arcConfiguration

let emailOption =
Expand All @@ -200,7 +200,7 @@ module ConfigurationAPI =
log.Trace("Retrieved user email from given argument.")
Some name
| None ->
log.Trace("Could not retrieve user email from argument. Try to retrieve it from ARC config.")
log.Info("Could not retrieve user email from argument. Try to retrieve it from ARC config.")
GeneralConfiguration.tryGetGitEmail arcConfiguration

match nameOption, emailOption with
Expand Down
1 change: 1 addition & 0 deletions src/ArcCommander/APIs/GitAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ module GitAPI =

if remoteExists() then
log.Trace("Pull")
if arcArgs.ContainsFlag ArcSyncArgs.NoLFS then GitHelper.setNoLFSConfig repoDir
executeGitCommand repoDir ("fetch origin") |> ignore
executeGitCommand repoDir ($"pull --rebase origin {branch}") |> ignore

Expand Down
2 changes: 1 addition & 1 deletion src/ArcCommander/APIs/InvestigationAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module InvestigationAPI =
let replaceWithEmptyValues = investigationArgs.ContainsFlag InvestigationUpdateArgs.ReplaceWithEmptyValues

let identifier =
investigationArgs.TryGetFieldValue InvestigationUpdateArgs.Identifier
investigationArgs.TryGetFieldValue InvestigationUpdateArgs.InvestigationIdentifier
|> Option.defaultValue (Identifier.createMissingIdentifier())

let investigation =
Expand Down
14 changes: 7 additions & 7 deletions src/ArcCommander/APIs/StudyAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module StudyAPI =

log.Info("Start Study Init")

let identifier = studyArgs.GetFieldValue StudyInitArgs.Identifier
let identifier = studyArgs.GetFieldValue StudyInitArgs.StudyIdentifier

let study =
ArcStudy.create(
Expand Down Expand Up @@ -73,7 +73,7 @@ module StudyAPI =
let replaceWithEmptyValues = studyArgs.ContainsFlag StudyUpdateArgs.ReplaceWithEmptyValues |> not
let addIfMissing = studyArgs.ContainsFlag StudyUpdateArgs.AddIfMissing

let identifier = studyArgs.GetFieldValue StudyUpdateArgs.Identifier
let identifier = studyArgs.GetFieldValue StudyUpdateArgs.StudyIdentifier

let study =
ArcStudy.create(
Expand Down Expand Up @@ -113,7 +113,7 @@ module StudyAPI =

let editor = GeneralConfiguration.getEditor arcConfiguration

let studyIdentifier = studyArgs.GetFieldValue StudyEditArgs.Identifier
let studyIdentifier = studyArgs.GetFieldValue StudyEditArgs.StudyIdentifier

let getNewStudy oldStudy =
ArgumentProcessing.Prompt.createIsaItemQuery
Expand Down Expand Up @@ -142,7 +142,7 @@ module StudyAPI =

log.Info("Start Study Register")

let identifier = studyArgs.GetFieldValue StudyRegisterArgs.Identifier
let identifier = studyArgs.GetFieldValue StudyRegisterArgs.StudyIdentifier

let arc = ARC.load(arcConfiguration)
let isa = arc.ISA |> Option.defaultValue (ArcInvestigation(Identifier.createMissingIdentifier()))
Expand All @@ -168,7 +168,7 @@ module StudyAPI =

let isForced = studyArgs.ContainsFlag StudyDeleteArgs.Force

let identifier = studyArgs.GetFieldValue StudyDeleteArgs.Identifier
let identifier = studyArgs.GetFieldValue StudyDeleteArgs.StudyIdentifier

let studyFolderPath = StudyConfiguration.getFolderPath identifier arcConfiguration

Expand Down Expand Up @@ -212,7 +212,7 @@ module StudyAPI =

log.Info("Start Study Unregister")

let identifier = studyArgs.GetFieldValue StudyUnregisterArgs.Identifier
let identifier = studyArgs.GetFieldValue StudyUnregisterArgs.StudyIdentifier

let arc = ARC.load(arcConfiguration)
let isa = arc.ISA |> Option.defaultValue (ArcInvestigation(Identifier.createMissingIdentifier()))
Expand All @@ -237,7 +237,7 @@ module StudyAPI =

log.Info("Start Study Show")

let identifier = studyArgs.GetFieldValue StudyShowArgs.Identifier
let identifier = studyArgs.GetFieldValue StudyShowArgs.StudyIdentifier

let arc = ARC.load(arcConfiguration)
let isa = arc.ISA |> Option.defaultValue (ArcInvestigation(Identifier.createMissingIdentifier()))
Expand Down
16 changes: 9 additions & 7 deletions src/ArcCommander/CLIArguments/ArcArgs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ArcConvertArgs =

type ArcInitArgs =

| [<AltCommandLine("-i")>][<Unique>] Identifier of identifier : string
| [<AltCommandLine("-i")>][<Unique>] InvestigationIdentifier of identifier : string
| [<AltCommandLine("-b")>][<Unique>] Branch of branch_name : string
// --repositoryadress is obsolete (previous spelling mistake)
| [<AltCommandLine("--repositoryadress")>][<AltCommandLine("-r")>][<Unique>] RepositoryAddress of repository_address : string
Expand All @@ -32,12 +32,12 @@ type ArcInitArgs =
interface IArgParserTemplate with
member this.Usage =
match this with
| Identifier _ -> "Identifier of the ARC. This value is used as the investigation identifier. Hint: If you're unsure about this, you can use the name of the ARC or any name that roughly hints to what your experiment is about."
| Branch _ -> "Name of the git branch to be created"
| 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"
| InvestigationIdentifier _ -> "Identifier of the ARC. This value is used as the investigation identifier. Hint: If you're unsure about this, you can use the name of the ARC or any name that roughly hints to what your experiment is about."
| Branch _ -> "Name of the git branch to be created"
| 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"

type ArcExportArgs =

Expand All @@ -56,6 +56,7 @@ type ArcSyncArgs =
| [<Unique>][<AltCommandLine("-r")>] RepositoryAddress of repository_address:string
| [<Unique>][<AltCommandLine("-m")>] CommitMessage of commit_message:string
| [<Unique>][<AltCommandLine("-b")>] Branch of branch:string
| [<Unique>][<AltCommandLine("-n")>] NoLFS
| [<Unique>][<AltCommandLine("-f")>] Force


Expand All @@ -65,6 +66,7 @@ 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."

/// TO-DO: Argumente anpassen
Expand Down
4 changes: 2 additions & 2 deletions src/ArcCommander/CLIArguments/InvestigationArgs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ open ArcCommander.ArgumentProcessing

/// CLI arguments updating the arc's existing investigation file
type InvestigationUpdateArgs =
| [<AltCommandLine("-i")>][<Unique>][<FileName>] Identifier of investigation_identifier:string
| [<AltCommandLine("-i")>][<Unique>][<FileName>] InvestigationIdentifier of investigation_identifier:string
| [<Unique>] Title of title:string
| [<Unique>] Description of description:string
| [<Unique>] SubmissionDate of submission_date:string
Expand All @@ -35,7 +35,7 @@ type InvestigationUpdateArgs =
interface IArgParserTemplate with
member this.Usage =
match this with
| Identifier _ -> "A identifier or an accession number provided by a repository. This SHOULD be locally unique."
| InvestigationIdentifier _ -> "A identifier or an accession number provided by a repository. This SHOULD be locally unique."
| Title _ -> "A concise name given to the investigation"
| Description _ -> "A textual description of the investigation"
| SubmissionDate _ -> "The date on which the investigation was reported to the repository"
Expand Down
16 changes: 8 additions & 8 deletions src/ArcCommander/CLIArguments/StudyArgs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ open ArcCommander.ArgumentProcessing

/// CLI arguments for interactively editing existing study metadata.
type StudyEditArgs =
| [<Mandatory>][<AltCommandLine("-s")>][<Unique>] Identifier of study_identifier : string
| [<Mandatory>][<AltCommandLine("-s")>][<Unique>] StudyIdentifier of study_identifier : string

interface IArgParserTemplate with
member this.Usage =
match this with
| Identifier _-> "A unique identifier, either a temporary identifier supplied by users or one generated by a repository or other database. For example, it could be an identifier complying with the LSID specification."
| StudyIdentifier _-> "A unique identifier, either a temporary identifier supplied by users or one generated by a repository or other database. For example, it could be an identifier complying with the LSID specification."

/// CLI arguments for updating existing study metadata.
type StudyUpdateArgs =
| [<Mandatory>][<AltCommandLine("-s")>][<Unique>][<FileName>] Identifier of study_identifier : string
| [<Mandatory>][<AltCommandLine("-s")>][<Unique>][<FileName>] StudyIdentifier of study_identifier : string
| [<Unique>] Title of title : string
| [<Unique>] Description of description : string
| [<Unique>] SubmissionDate of submission_date : string
Expand All @@ -25,7 +25,7 @@ type StudyUpdateArgs =
interface IArgParserTemplate with
member this.Usage =
match this with
| Identifier _ -> "A unique identifier, either a temporary identifier supplied by users or one generated by a repository or other database. For example, it could be an identifier complying with the LSID specification."
| StudyIdentifier _ -> "A unique identifier, either a temporary identifier supplied by users or one generated by a repository or other database. For example, it could be an identifier complying with the LSID specification."
| Title _ -> "A concise phrase used to encapsulate the purpose and goal of the study"
| Description _ -> "A textual description of the study, with components such as objective or goals"
| SubmissionDate _ -> "The date on which the study is submitted to an archive"
Expand All @@ -36,7 +36,7 @@ type StudyUpdateArgs =

/// CLI arguments for registering existing study metadata.
type StudyInitArgs =
| [<Mandatory>][<AltCommandLine("-s")>][<Unique>][<FileName>] Identifier of study_identifier : string
| [<Mandatory>][<AltCommandLine("-s")>][<Unique>][<FileName>] StudyIdentifier of study_identifier : string
| [<Unique>] Title of title : string
| [<Unique>] Description of description : string
| [<Unique>] SubmissionDate of submission_date : string
Expand All @@ -45,7 +45,7 @@ type StudyInitArgs =
interface IArgParserTemplate with
member this.Usage =
match this with
| Identifier _-> "A unique identifier, either a temporary identifier supplied by users or one generated by a repository or other database. For example, it could be an identifier complying with the LSID specification."
| StudyIdentifier _-> "A unique identifier, either a temporary identifier supplied by users or one generated by a repository or other database. For example, it could be an identifier complying with the LSID specification."
| Title _-> "A concise phrase used to encapsulate the purpose and goal of the study"
| Description _-> "A textual description of the study, with components such as objective or goals"
| SubmissionDate _-> "The date on which the study is submitted to an archive"
Expand All @@ -61,13 +61,13 @@ type StudyAddArgs = StudyInitArgs

/// CLI arguments for study deletion.
type StudyDeleteArgs =
| [<Mandatory>][<AltCommandLine("-s")>][<Unique>] Identifier of study_identifier : string
| [<Mandatory>][<AltCommandLine("-s")>][<Unique>] StudyIdentifier of study_identifier : string
| [<Unique>] Force

interface IArgParserTemplate with
member this.Usage =
match this with
| Identifier _ -> "A unique identifier, either a temporary identifier supplied by users or one generated by a repository or other database. For example, it could be an identifier complying with the LSID specification."
| StudyIdentifier _ -> "A unique identifier, either a temporary identifier supplied by users or one generated by a repository or other database. For example, it could be an identifier complying with the LSID specification."
| Force -> "Forces deletion of all subfolders and -files, no matter if they are user-specific or not"

/// CLI arguments for study removal.
Expand Down
4 changes: 4 additions & 0 deletions src/ArcCommander/GitHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ module GitHelper =

let noLFSConfig = "-c \"filter.lfs.smudge = git-lfs smudge --skip -- %f\" -c \"filter.lfs.process = git-lfs filter-process --skip\""

let setNoLFSConfig dir =
executeGitCommand dir ("config --local --replace-all \"filter.lfs.process\" \"git-lfs filter-process --skip\"")
executeGitCommand dir ("config --local --replace-all \"git-lfs smudge --skip -- %f\" \"git-lfs filter-process --skip\"")

let cloneNoLFS dir url =
executeGitCommand dir (sprintf "clone %s %s" noLFSConfig url)

Expand Down
14 changes: 7 additions & 7 deletions tests/ArcCommander.Tests/ArcTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let testArcInit =
testCase "Simple" (fun () ->
let config = createConfigFromDir testListName "Simple"
let identifier = "MyInvestigation"
let investigationArgs = [ArcInitArgs.Identifier identifier]
let investigationArgs = [ArcInitArgs.InvestigationIdentifier identifier]

processCommand config ArcAPI.init investigationArgs

Expand All @@ -44,10 +44,10 @@ let testArcInit =
testCase "ShouldNotOverwrite" (fun () ->
let config = createConfigFromDir testListName "Simple"
let identifier = "MyInvestigation"
let investigationArgs = [ArcInitArgs.Identifier identifier]
let investigationArgs = [ArcInitArgs.InvestigationIdentifier identifier]

let secondIdentifier = "MySecondInvestigation"
let secondInvestigationArgs = [ArcInitArgs.Identifier secondIdentifier]
let secondInvestigationArgs = [ArcInitArgs.InvestigationIdentifier secondIdentifier]

processCommand config ArcAPI.init investigationArgs
processCommand config ArcAPI.init secondInvestigationArgs
Expand Down Expand Up @@ -78,7 +78,7 @@ let testArcUpdate =
let config = createConfigFromDir testListName "DontPutAssayPerformerIntoStudy"

let identifier = "MyInvestigation"
let investigationArgs = [ArcInitArgs.Identifier identifier]
let investigationArgs = [ArcInitArgs.InvestigationIdentifier identifier]
processCommand config ArcAPI.init investigationArgs

let assayIdentifier = "MyAssay"
Expand Down Expand Up @@ -112,7 +112,7 @@ let testArcExport =
let config = createConfigFromDir testListName "Simple"

let identifier = "MyInvestigation"
let investigationArgs = [ArcInitArgs.Identifier identifier]
let investigationArgs = [ArcInitArgs.InvestigationIdentifier identifier]
processCommand config ArcAPI.init investigationArgs

let assayIdentifier = "MyAssay"
Expand All @@ -137,7 +137,7 @@ let testArcExport =
let config = createConfigFromDir testListName "OnlyExportRegistered"

let identifier = "MyInvestigation"
let investigationArgs = [ArcInitArgs.Identifier identifier]
let investigationArgs = [ArcInitArgs.InvestigationIdentifier identifier]
processCommand config ArcAPI.init investigationArgs

let registeredAssayIdentifier = "RegisteredAssay"
Expand All @@ -149,7 +149,7 @@ let testArcExport =
processCommand config AssayAPI.init assayArgs

let unregisteredStudyIdentifier = "UnregisteredStudy"
let studyArgs = [StudyInitArgs.Identifier unregisteredStudyIdentifier]
let studyArgs = [StudyInitArgs.StudyIdentifier unregisteredStudyIdentifier]
processCommand config StudyAPI.init studyArgs

let exportPath = Path.Combine(GeneralConfiguration.getWorkDirectory config, "export.json")
Expand Down
Loading