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

Generic LDNodes and RO-Crate parsing rework #496

Open
wants to merge 56 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
b434ade
Add LDObject.tryFromDynamicObj + tests
kMutagene Nov 20, 2024
e5efa2f
LDObject: model `@type`/`additionalType` as arrays:
kMutagene Nov 21, 2024
556adb3
Fix running single test projects
kMutagene Dec 19, 2024
10ab9a3
some LDObject parsing fixes
HLWeil Jan 24, 2025
0eab82a
wip LDObject from dynamic obj
kMutagene Jan 28, 2025
7de9bdf
update DynamicObj dependency and fix for LDObject from DynamicObj
HLWeil Jan 28, 2025
0ad4df6
fix LDObject from DynamicObj function
HLWeil Jan 29, 2025
bc55487
add basic ld context resolving
HLWeil Feb 7, 2025
015410a
add ro-crate 1.1 context
HLWeil Feb 10, 2025
c69106a
make ldcontext term resolution recursive
HLWeil Feb 11, 2025
e7a8c6c
split up LDObject into LDNode, LDRef and LDValue
HLWeil Feb 12, 2025
7b62486
add basic LD form algorithms
HLWeil Feb 13, 2025
4222bc3
start working on basic generic LDNode access classes
HLWeil Feb 13, 2025
664b86b
add basic LDContext tests
HLWeil Feb 14, 2025
bda9098
add context copy tests
HLWeil Feb 14, 2025
bd11928
start working on ldnode tests
HLWeil Feb 14, 2025
1c43c6d
add basic ldnode tests
HLWeil Feb 17, 2025
1ca9ac9
some fixes for ldnodes according to tests
HLWeil Feb 17, 2025
27db166
add ldnode compact and flatten tests
HLWeil Feb 17, 2025
477f921
start on ldnode json io
HLWeil Feb 19, 2025
030c9c3
add various ldobject json parsing tests
HLWeil Feb 20, 2025
c9c6020
add basic ldgraph test and context parsing hotfixes fixes
HLWeil Feb 20, 2025
48efd4f
add some static types from isa-ro-crate profile
HLWeil Feb 20, 2025
59edad3
add labprocess and labprotocol rocrate static classes
HLWeil Feb 21, 2025
05d5ea6
start working on scaffold RO-Crate type conversion
HLWeil Feb 21, 2025
fdb4f16
finish up preliminary version of Scaffold ROCrate Process conversion
HLWeil Feb 22, 2025
633438c
add and update first bulk of RO-Crate Scaffold conversion tests
HLWeil Feb 23, 2025
90647e0
some LabProcess Table conversion fixes
HLWeil Feb 24, 2025
e1dc2cb
fix remaining LabProcess ArcTable conversion errors
HLWeil Feb 24, 2025
f18abad
start working on top level RO Crate types and conversions
HLWeil Feb 24, 2025
cee2744
add Scaffold ROCrate conversion functions for persons
HLWeil Feb 25, 2025
93c9bfd
add scholarlyarticle conversion and tests
HLWeil Feb 25, 2025
6ec7039
implement first version of ROCrate Scaffold dataset converters
HLWeil Feb 25, 2025
1bb84f2
add rocrate scaffold conversion dataset tests
HLWeil Feb 26, 2025
5fc62f1
test and fix rocrate scaffold conversion using flattened graph
HLWeil Feb 26, 2025
8c32287
small fixes of tests against dotnet
HLWeil Feb 26, 2025
861bff6
start working on ROCrate Fable compatability
HLWeil Feb 26, 2025
dd3e5e1
continue fixing rocrate for javascript
HLWeil Feb 26, 2025
9795ef4
fix rocrate for python
HLWeil Feb 27, 2025
772a901
fix jsnative
HLWeil Feb 27, 2025
d8897c1
add ldnode merge function
HLWeil Feb 27, 2025
a0ceff9
add functionality to merge LDNodes into LDGraph
HLWeil Feb 27, 2025
f765891
various small fixes to RO-Crate parsing
HLWeil Feb 27, 2025
0b59c4b
improve ROCrate context parsing
HLWeil Feb 27, 2025
d43845e
add doi and pubmedid identifier handling
HLWeil Feb 27, 2025
b239c35
fix js and py
HLWeil Feb 27, 2025
3fa2701
add defaults for requried RO-Crate fields
HLWeil Mar 3, 2025
1358454
small changes to generated @ids in ro-crate
HLWeil Mar 3, 2025
e392461
first version of making data file paths absolute to ARC-Root
HLWeil Mar 3, 2025
0e9a4d7
add behaviour to fill assay and study hasParts with datafiles
HLWeil Mar 3, 2025
308098f
various fixes to improve `@id`s in Json-LD writing
HLWeil Mar 4, 2025
d3d786e
add new ArcPrototype RO-Crate testfiles
HLWeil Mar 4, 2025
23d38dd
small fix to rocrate conversion test
HLWeil Mar 4, 2025
6e3e1fd
extend LDContext functionality by compactIRI reverse resolving
HLWeil Mar 4, 2025
1e3ad23
add fromDeprecatedRoCrate function and some fixes
HLWeil Mar 4, 2025
6cf8105
add ro-crate parsing tests
HLWeil Mar 4, 2025
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 Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageVersion Include="FsSpreadsheet.Js" Version="6.3.1" />
<PackageVersion Include="FsSpreadsheet.Py" Version="6.3.1" />
<PackageVersion Include="YAMLicious" Version="0.0.3" />
<PackageVersion Include="DynamicObj" Version="4.0.3" />
<PackageVersion Include="DynamicObj" Version="7.0.1" />
<PackageVersion Include="Fable.SimpleHttp" Version="3.5.0" />
<PackageVersion Include="Fable.Fetch" Version="2.6.0" />
<PackageVersion Include="Fable.Node" Version="1.2.0" />
Expand Down
21 changes: 12 additions & 9 deletions build/ProjectInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ open Helpers

let project = "ARCtrl"

let allTestsProject = "tests/All"

/// Dotnet and JS test paths
let testProjects =
[
"tests/All"
//"tests/Core"
//"tests/Json"
//"tests/Spreadsheet"
//"tests/FileSystem"
//"tests/ARCtrl"
//"tests/Yaml"
//"tests/ValidationPackages"
//"tests/Contract"
//"tests/ROCrate"
"tests/ARCtrl"
"tests/Contract"
"tests/Core"
"tests/CWL"
"tests/FileSystem"
"tests/Json"
"tests/ROCrate"
"tests/Spreadsheet"
"tests/ValidationPackages"
"tests/Yaml"
]

/// Native JS test paths
Expand Down
46 changes: 27 additions & 19 deletions build/TestTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ open Fake.DotNet
open ProjectInfo
open BasicTasks
open Fake.Core
open Fake.IO
open Fake.IO.Globbing.Operators

module RunTests =

Expand Down Expand Up @@ -33,19 +35,26 @@ module RunTests =
Trace.traceImportant "Skipping JavaScript tests"
)

let prePareJsTests = BuildTask.create "PrepareJsTests" [] {
!! "tests/TestingUtils/TestResults"
|> Shell.cleanDirs
System.IO.Directory.CreateDirectory("./tests/TestingUtils/TestResults/js") |> ignore
//System.IO.File.Copy(jsHelperFilePath, $"{allTestsProject}/js/{jsHelperFileName}") |> ignore

}


let runTestsJs = BuildTask.createFn "runTestsJS" [clean] (fun tp ->
if tp.Context.Arguments |> List.exists (fun a -> a.ToLower() = skipTestsFlag.ToLower()) |> not then
Trace.traceImportant "Start Js tests"
for path in ProjectInfo.testProjects do
// Setup test results directory after clean
System.IO.Directory.CreateDirectory("./tests/TestingUtils/TestResults/js") |> ignore
// transpile js files from fsharp code
run dotnet $"fable {path} -o {path}/js --nocache" ""

System.IO.File.Copy(jsHelperFilePath, $"{path}/js/{jsHelperFileName}") |> ignore
// run mocha in target path to execute tests
// "--timeout 20000" is used, because json schema validation takes a bit of time.
run node $"{path}/js/Main.js" ""
// Setup test results directory after clean
System.IO.Directory.CreateDirectory("./tests/TestingUtils/TestResults/js") |> ignore
// transpile js files from fsharp code
run dotnet $"fable {allTestsProject} -o {allTestsProject}/js --nocache" ""
System.IO.File.Copy(jsHelperFilePath, $"{allTestsProject}/js/{jsHelperFileName}") |> ignore
// run mocha in target path to execute tests
// "--timeout 20000" is used, because json schema validation takes a bit of time.
run node $"{allTestsProject}/js/Main.js" ""
else
Trace.traceImportant "Skipping Js tests"
)
Expand All @@ -65,13 +74,12 @@ module RunTests =
let runTestsPy = BuildTask.createFn "runTestsPy" [clean] (fun tp ->
if tp.Context.Arguments |> List.exists (fun a -> a.ToLower() = skipTestsFlag.ToLower()) |> not then
Trace.traceImportant "Start Python tests"
for path in ProjectInfo.testProjects do
// Setup test results directory after clean
System.IO.Directory.CreateDirectory("./tests/TestingUtils/TestResults/py") |> ignore
//transpile py files from fsharp code
run dotnet $"fable {path} -o {path}/py --lang python --nocache" ""
// run pyxpecto in target path to execute tests in python
run python $"{path}/py/main.py" ""
// Setup test results directory after clean
System.IO.Directory.CreateDirectory("./tests/TestingUtils/TestResults/py") |> ignore
//transpile py files from fsharp code
run dotnet $"fable {allTestsProject} -o {allTestsProject}/py --lang python --nocache" ""
// run pyxpecto in target path to execute tests in python
run python $"{allTestsProject}/py/main.py" ""
else
Trace.traceImportant "Skipping Python tests"

Expand All @@ -81,8 +89,7 @@ module RunTests =
if tp.Context.Arguments |> List.exists (fun a -> a.ToLower() = skipTestsFlag.ToLower()) |> not then
Trace.traceImportant "Start .NET tests"
let dotnetRun = run dotnet "run"
testProjects
|> Seq.iter dotnetRun
dotnetRun allTestsProject
else
Trace.traceImportant "Skipping .NET tests"
)
Expand All @@ -105,6 +112,7 @@ module RunTests =
run python $"{p}/py/main.py" ""
// transpile js files from fsharp code
run dotnet $"fable {p} -o {p}/js" ""
System.IO.Directory.CreateDirectory("./tests/TestingUtils/TestResults/js") |> ignore
System.IO.File.Copy(jsHelperFilePath, $"{p}/js/{jsHelperFileName}") |> ignore
// run mocha in target path to execute tests
// "--timeout 20000" is used, because json schema validation takes a bit of time.
Expand Down
72 changes: 69 additions & 3 deletions src/ARCtrl/ARC.fs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,59 @@ type ARC(?isa : ArcInvestigation, ?cwl : unit, ?fs : FileSystem.FileSystem) =
#endif


member this.MakeDataFilesAbsolute() =
let filesPaths = this.FileSystem.Tree.ToFilePaths() |> set
let checkExistenceFromRoot = fun p -> filesPaths |> Set.contains p
match this.ISA with
| Some inv ->
inv.Studies |> Seq.iter (fun s ->
s.Tables |> Seq.iter (fun t ->
match t.TryGetInputColumn() with
| Some col when col.Header.IsDataColumn ->
col.Cells |> Array.iter (fun c ->
if c.AsData.FilePath.IsSome then

let newFilePath =
c.AsData.GetAbsolutePathForStudy(s.Identifier,checkExistenceFromRoot)
c.AsData.FilePath <- Some newFilePath
)
| _ -> ()
match t.TryGetOutputColumn() with
| Some col when col.Header.IsDataColumn ->
col.Cells |> Array.iter (fun c ->
if c.AsData.FilePath.IsSome then
let newFilePath =
c.AsData.GetAbsolutePathForStudy(s.Identifier,checkExistenceFromRoot)
c.AsData.FilePath <- Some newFilePath
)
| _ -> ()
)
)
inv.Assays |> Seq.iter (fun a ->
a.Tables |> Seq.iter (fun t ->
match t.TryGetInputColumn() with
| Some col when col.Header.IsDataColumn ->
col.Cells |> Array.iter (fun c ->
if c.AsData.FilePath.IsSome then
let newFilePath =
c.AsData.GetAbsolutePathForAssay (a.Identifier,checkExistenceFromRoot)
c.AsData.FilePath <- Some newFilePath
)
| _ -> ()
match t.TryGetOutputColumn() with
| Some col when col.Header.IsDataColumn ->
col.Cells |> Array.iter (fun c ->
if c.AsData.FilePath.IsSome then
let newFilePath =
c.AsData.GetAbsolutePathForAssay (a.Identifier,checkExistenceFromRoot)
c.AsData.FilePath <- Some newFilePath
)
| _ -> ()
)
)
| None -> ()


//static member updateISA (isa : ISA.Investigation) (arc : ARC) : ARC =
// raise (System.NotImplementedException())

Expand Down Expand Up @@ -701,11 +754,24 @@ type ARC(?isa : ArcInvestigation, ?cwl : unit, ?fs : FileSystem.FileSystem) =
ARCtrl.Contract.Git.gitattributesFileName, ARCtrl.Contract.Git.gitattributesContract
|]

static member fromROCrateJsonString (s:string) =
let isa = ARCtrl.Json.Decode.fromJsonString ARCtrl.Json.ARC.ROCrate.decoder s
ARC(?isa = isa)
static member fromDeprecatedROCrateJsonString (s:string) =
try
let isa = ARCtrl.Json.Decode.fromJsonString ARCtrl.Json.ARC.ROCrate.decoderDeprecated s
ARC(isa = isa)
with
| ex ->
failwithf "Could not parse deprecated ARC-RO-Crate metadata: \n%s" ex.Message

static member fromROCrateJsonString (s:string) =
try
let isa = ARCtrl.Json.Decode.fromJsonString ARCtrl.Json.ARC.ROCrate.decoder s
ARC(isa = isa)
with
| ex ->
failwithf "Could not parse ARC-RO-Crate metadata: \n%s" ex.Message

member this.ToROCrateJsonString(?spaces) =
this.MakeDataFilesAbsolute()
ARCtrl.Json.ARC.ROCrate.encoder (Option.get _isa)
|> ARCtrl.Json.Encode.toJsonString (ARCtrl.Json.Encode.defaultSpaces spaces)

Expand Down
4 changes: 3 additions & 1 deletion src/ARCtrl/ARCtrl.Javascript.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<Content Include="ARCtrl.Common.props" Pack="true" PackagePath="fable/" />
<Compile Include="ColumnIndex.fs" />
<Compile Include="JsonIO\Decode.fs" />
<Compile Include="JsonIO\Encode.fs" />
<Compile Include="JsonIO\Comment.fs" />
Expand Down Expand Up @@ -48,7 +49,8 @@
<Compile Include="JsonIO\Study.fs" />
<Compile Include="JsonIO\Investigation.fs" />
<Compile Include="JsonIO\LDObject.fs" />
<Compile Include="JsonIO\ARC.fs" />
<Compile Include="Conversion.fs" />
<Compile Include="ROCrateIO.fs" />
<Compile Include="CrossAsync.fs" />
<None Include="README.md" />
</ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/ARCtrl/ARCtrl.Python.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<None Include="README.md" />
<Compile Include="CrossAsync.fs" />
<Content Include="ARCtrl.Common.props" Pack="true" PackagePath="fable/" />
<Compile Include="ColumnIndex.fs" />
<Compile Include="JsonIO\Decode.fs" />
<Compile Include="JsonIO\Encode.fs" />
<Compile Include="JsonIO\Comment.fs" />
Expand Down Expand Up @@ -50,7 +51,8 @@
<Compile Include="JsonIO\Study.fs" />
<Compile Include="JsonIO\Investigation.fs" />
<Compile Include="JsonIO\LDObject.fs" />
<Compile Include="JsonIO\ARC.fs" />
<Compile Include="Conversion.fs" />
<Compile Include="ROCrateIO.fs" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 6 additions & 4 deletions src/ARCtrl/ARCtrl.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ItemGroup>
<None Include="README.md" />
<Content Include="ARCtrl.Common.props" Pack="true" PackagePath="fable/" />
<Compile Include="ColumnIndex.fs" />
<Compile Include="JsonIO\Decode.fs" />
<Compile Include="JsonIO\Encode.fs" />
<Compile Include="JsonIO\Comment.fs" />
Expand Down Expand Up @@ -48,13 +49,14 @@
<Compile Include="JsonIO\Study.fs" />
<Compile Include="JsonIO\Investigation.fs" />
<Compile Include="JsonIO\LDObject.fs" />
<Compile Include="JsonIO\ARC.fs" />
<Compile Include="Conversion.fs" />
<Compile Include="ROCrateIO.fs" />
</ItemGroup>

<ItemGroup>
<Compile Include ="CrossAsync.fs" />
<Compile Include ="ContractIO\FileSystemHelper.fs" />
<Compile Include ="ContractIO\ContractIO.fs" />
<Compile Include="CrossAsync.fs" />
<Compile Include="ContractIO\FileSystemHelper.fs" />
<Compile Include="ContractIO\ContractIO.fs" />
<Compile Include="WebRequest\WebRequest.fs" />
<Compile Include="Template.Web.fs" />
<Compile Include="ARC.fs" />
Expand Down
Loading
Loading