Skip to content

Commit

Permalink
add new metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Feb 29, 2024
1 parent 62c5fd2 commit 592dd65
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 29 deletions.
66 changes: 59 additions & 7 deletions scripts/domain.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@

open System
open System.IO
open System.Security.Cryptography
open YamlDotNet.Serialization
open System.Text.Json
// open ARCValidationPackages <-- use this (or ARCtrl) once the data model is stable

[<AutoOpen>]
module Constants =

let [<Literal>] STAGING_AREA_RELATIVE_PATH = "src/PackageRegistryService/StagingArea"
let [<Literal>] PACKAGE_INDEX_RELATIVE_PATH = "src/PackageRegistryService/Data/arc-validate-package-index.json"

// This is the F# version of /src/PackageRegistryService/Models/ValidationPackageIndex.cs
// and should be equal to the implementation in arc-validate (until there is a common codebase/domain)
[<AutoOpen>]
Expand Down Expand Up @@ -45,22 +52,51 @@ module Domain =
)
| _ -> false

type OntologyAnnotation() =

member val Name = "" with get,set
member val TermSourceREF = "" with get,set
member val TermAccessionNumber = "" with get,set

override this.GetHashCode() =
hash (
this.Name,
this.TermSourceREF,
this.TermAccessionNumber
)

override this.Equals(other) =
match other with
| :? OntologyAnnotation as oa ->
(
this.Name,
this.TermSourceREF,
this.TermAccessionNumber
) = (
oa.Name,
oa.TermSourceREF,
oa.TermAccessionNumber
)
| _ -> false

type ValidationPackageMetadata() =
// mandatory fields
member val Name = "" with get,set
member val Summary = "" with get,set
member val Description = "" with get,set
member val MajorVersion = 0 with get,set
member val MinorVersion = 0 with get,set
member val PatchVersion = 0 with get,set
// optional fields
member val Publish = false with get,set
member val Authors: Author [] = Array.empty<Author> with get,set
member val Tags: string [] = Array.empty<string> with get,set
member val Tags: OntologyAnnotation [] = Array.empty<OntologyAnnotation> with get,set
member val ReleaseNotes = "" with get,set

override this.GetHashCode() =
hash (
this.Name,
this.Summary,
this.Description,
this.MajorVersion,
this.MinorVersion,
Expand All @@ -76,6 +112,7 @@ module Domain =
| :? ValidationPackageMetadata as vpm ->
(
this.Name,
this.Summary,
this.Description,
this.MajorVersion,
this.MinorVersion,
Expand All @@ -86,6 +123,7 @@ module Domain =
this.ReleaseNotes
) = (
vpm.Name,
vpm.Summary,
vpm.Description,
vpm.MajorVersion,
vpm.MinorVersion,
Expand Down Expand Up @@ -125,7 +163,7 @@ module Domain =
metadata: ValidationPackageMetadata
) =

let md5 = System.Security.Cryptography.MD5.Create()
let md5 = MD5.Create()

ValidationPackageIndex.create(
repoPath = repoPath,
Expand Down Expand Up @@ -212,11 +250,18 @@ module Utils =
System.Globalization.CultureInfo.InvariantCulture
)

module AVPRRepo =
type AVPRRepo =

///! Paths are relative to the root of the project, since the script is executed from the repo root in CI
let getStagedPackages() =
Directory.GetFiles("src/PackageRegistryService/StagingArea", "*.fsx", SearchOption.AllDirectories)
/// Path is adjustable by passing `RepoRoot`
static member getStagedPackages(?RepoRoot: string) =

let path =
defaultArg
(RepoRoot |> Option.map (fun p -> Path.Combine(p, STAGING_AREA_RELATIVE_PATH)))
STAGING_AREA_RELATIVE_PATH

Directory.GetFiles(path, "*.fsx", SearchOption.AllDirectories)
|> Array.map (fun x -> x.Replace('\\',Path.DirectorySeparatorChar).Replace('/',Path.DirectorySeparatorChar))
|> Array.map (fun p ->
ValidationPackageIndex.create(
Expand All @@ -226,8 +271,15 @@ module AVPRRepo =
)

///! Paths are relative to the root of the project, since the script is executed from the repo root in CI
let getIndexedPackages() =
"src/PackageRegistryService/Data/arc-validate-package-index.json"
/// Path is adjustable by passing `RepoRoot`
static member getIndexedPackages(?RepoRoot: string) =

let path =
defaultArg
(RepoRoot |> Option.map (fun p -> Path.Combine(p, PACKAGE_INDEX_RELATIVE_PATH)))
PACKAGE_INDEX_RELATIVE_PATH

path
|> File.ReadAllText
|> JsonSerializer.Deserialize<ValidationPackageIndex[]>

65 changes: 51 additions & 14 deletions src/PackageRegistryService/Data/arc-validate-package-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
{
"RepoPath": "src/PackageRegistryService/StagingArea/invenio/invenio@1.0.0.fsx",
"FileName": "invenio@1.0.0.fsx",
"LastUpdated": "2024-02-28T15:39:07+01:00",
"ContentHash": "1A3CB3CC0538782C864EA37545451FD5",
"LastUpdated": "2024-02-29T14:45:26+01:00",
"ContentHash": "864458DA6C7B0F08A546210CFD3CCA4A",
"Metadata": {
"Name": "invenio",
"Summary": "",
"Description": "Validates if the ARC contains the necessary metadata to be publishable via Invenio.\nThe following metadata is required:\n - Investigation has title and description\n - All persons in Investigation Contacts must have a name, last name, affiliation and valid email\n",
"MajorVersion": 1,
"MinorVersion": 0,
Expand All @@ -20,8 +21,16 @@
}
],
"Tags": [
"ARC",
"data publication"
{
"Name": "ARC",
"TermSourceREF": "",
"TermAccessionNumber": ""
},
{
"Name": "data publication",
"TermSourceREF": "",
"TermAccessionNumber": ""
}
],
"ReleaseNotes": "Initial release"
}
Expand All @@ -33,6 +42,7 @@
"ContentHash": "43BFF4CDCC3F3EBB3CA21B6C1F8AC5BA",
"Metadata": {
"Name": "test",
"Summary": "",
"Description": "this package is here for testing purposes only.",
"MajorVersion": 1,
"MinorVersion": 0,
Expand All @@ -50,6 +60,7 @@
"ContentHash": "0B9CBA89F1CECFAF5EB0BA1CE6A480FA",
"Metadata": {
"Name": "test",
"Summary": "",
"Description": "this package is here for testing purposes only.",
"MajorVersion": 1,
"MinorVersion": 0,
Expand All @@ -63,10 +74,11 @@
{
"RepoPath": "src/PackageRegistryService/StagingArea/test/test@2.0.0.fsx",
"FileName": "test@2.0.0.fsx",
"LastUpdated": "2024-02-28T15:39:07+01:00",
"ContentHash": "F819359C06456B62F035F2587FBE1EE2",
"LastUpdated": "2024-02-29T14:45:26+01:00",
"ContentHash": "40729E451689807AEFF17F5932843A4C",
"Metadata": {
"Name": "test",
"Summary": "",
"Description": "this package is here for testing purposes only.",
"MajorVersion": 2,
"MinorVersion": 0,
Expand All @@ -87,20 +99,33 @@
}
],
"Tags": [
"validation",
"my-package",
"thing"
{
"Name": "validation",
"TermSourceREF": "",
"TermAccessionNumber": ""
},
{
"Name": "my-package",
"TermSourceREF": "",
"TermAccessionNumber": ""
},
{
"Name": "thing",
"TermSourceREF": "",
"TermAccessionNumber": ""
}
],
"ReleaseNotes": "add authors and tags for further testing"
}
},
{
"RepoPath": "src/PackageRegistryService/StagingArea/test/test@3.0.0.fsx",
"FileName": "test@3.0.0.fsx",
"LastUpdated": "2024-02-28T15:39:07+01:00",
"ContentHash": "9E6AB1A9C908DE02F583D9FD0E76D8FA",
"LastUpdated": "2024-02-29T14:45:26+01:00",
"ContentHash": "0537642158095CE84F4FA8363225831E",
"Metadata": {
"Name": "test",
"Summary": "",
"Description": "this package is here for testing purposes only.",
"MajorVersion": 3,
"MinorVersion": 0,
Expand All @@ -121,9 +146,21 @@
}
],
"Tags": [
"validation",
"my-package",
"thing"
{
"Name": "validation",
"TermSourceREF": "",
"TermAccessionNumber": ""
},
{
"Name": "my-package",
"TermSourceREF": "",
"TermAccessionNumber": ""
},
{
"Name": "thing",
"TermSourceREF": "",
"TermAccessionNumber": ""
}
],
"ReleaseNotes": "add authors and tags for further testing"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Authors:
- FullName: Oliver Maus
Affiliation: DataPLANT
Tags:
- ARC
- data publication
- Name: ARC
- Name: data publication
ReleaseNotes: "Initial release"
---
*)
Expand Down
6 changes: 3 additions & 3 deletions src/PackageRegistryService/StagingArea/test/test@2.0.0.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Authors:
Affiliation: University of Somewhere
AffiliationLink: https://somewhere.edu
Tags:
- validation
- my-package
- thing
- Name: validation
- Name: my-package
- Name: thing
ReleaseNotes: "add authors and tags for further testing"
---
*)
Expand Down
6 changes: 3 additions & 3 deletions src/PackageRegistryService/StagingArea/test/test@3.0.0.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Authors:
Affiliation: University of Somewhere
AffiliationLink: https://somewhere.edu
Tags:
- validation
- my-package
- thing
- Name: validation
- Name: my-package
- Name: thing
ReleaseNotes: "add authors and tags for further testing"
---
*)
Expand Down

0 comments on commit 592dd65

Please sign in to comment.