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

Ro crate data model #426

Merged
merged 15 commits into from
Sep 5, 2024
Merged

Ro crate data model #426

merged 15 commits into from
Sep 5, 2024

Conversation

kMutagene
Copy link
Member

@kMutagene kMutagene commented Aug 27, 2024

This PR aims to provide the base classes to implement direct data models for the following ARC RO-Crate profiles:

Note that this currently only implements the ISA profile as that is the only "stable" profile yet.

The data model is currently implementing a common IROCrateObject interface with access to @id, @type and an optional additionalType.

Furthermore, all classes inherit from DynamicObj, which is transpilable as of CSBiology/DynamicObj#23, meaning we enable the general addition of any property to these classes.

The current design aims for the least static typing possible, leaving casting up to the caller. This neatly circumvents possible complicated type modelling e.g. for properties that can have multiple types joined via OR.

Parsing, writing, or any interop/conversion with the existing data models will be subject of other PRs

Further additions:

  • Introduce a runTestProject build target, that runs a single test project in all 3 languages. Use it like this: build.cmd runtestProject <name>, e.g. .\build.cmd runTestProject ROCrate

@kMutagene
Copy link
Member Author

kMutagene commented Sep 4, 2024

I think this is ready for a first round of review @HLWeil.

While there is still a lot to do, i would like to prevent this PR from becoming a long-running feature branch. When the base profile type implementation is fine, i would like to get it merged soon so that small additions and improvements to that API can be done incrementally in smaller workpackages/PRs.

@kMutagene kMutagene marked this pull request as ready for review September 4, 2024 07:16
@kMutagene kMutagene linked an issue Sep 4, 2024 that may be closed by this pull request
Copy link
Member

@HLWeil HLWeil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly asking for clarifications for documentation purposes

@@ -59,6 +59,33 @@ module RunTests =
|> Seq.iter dotnetRun
}

let runTestProject = BuildTask.createFn "runTestProject" [clean; build] (fun config ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

open DynamicObj

/// Base interface implemented by all explicitly known objects in our ROCrate profiles.
type IROCrateObject =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about context?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something i'd count under "add later in smaller PRs"

let mutable _schemaType = schemaType
let mutable _additionalType = additionalType

member this.Id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the decision to duplicate the properties exclusively on the type and in the interface? Is it because of ease of access?
Also, is it by design that the members are gettable and settable on the exclusive implementation but only gettable on the implementation of the interface?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the decision to duplicate the properties exclusively on the type and in the interface? Is it because of ease of access

type A =
    abstract member B: string

type C() =
    interface A with 
        member this.B = "lol nah"

let lol = C()

lol.B // <- does not work
(lol :> A).B // <- must cast to access member B

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is it by design that the members are gettable and settable on the exclusive implementation but only gettable on the implementation of the interface?

I think this is oversight on my part, forgetting updating the interface after making the members mutable. However, i am not so sure we even need the interface. I'd keep it for now to see if it is needed for our implementation purposes as first expected, and remove it if it is not needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -2,5 +2,4 @@

set PYTHONIOENCODING=utf-8
dotnet tool restore
cls
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh 😅

inherit ROCrateObject(id = id, schemaType = "schema.org/Dataset", ?additionalType = additionalType)

//interface implementations
interface IROCrateObject with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the explicit implementation of the interface again here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, this is unnecessary as it is already implemented by the superclass ROCrateObject

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

//interface implementations
interface IROCrateObject with
member this.Id with get () = this.Id
member this.SchemaType with get (): string = this.SchemaType
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No property retrieval helpers yet?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before, filed under "let's add that in another PR"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

) as this =
inherit Dataset(id, "Investigation")
do
// Properties from CreativeWork
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? Dataset is a child of CreativeWork

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just ignore them comments, leftovers

///
[<AttachMembers>]
type Dataset (id: string, ?additionalType: string) =
inherit ROCrateObject(id = id, schemaType = "schema.org/Dataset", ?additionalType = additionalType)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add type CreativeWork and let Dataset inherit it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or not because of the different subtypes of CreativeWork needing different properties of it?

Copy link
Member Author

@kMutagene kMutagene Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we need an explicit CreativeWork type, as we never use it anywhere else (meaining it can be realized as a generic ROCrateObject for all intents and purposes ). Dataset in contrast is parent of I/S/A and there might be an advantage of being able to return all of them as e.g. a Dataset list

@@ -0,0 +1,38 @@
module Tests.Common
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for now, but when everything is settled we should move it to TestingUtils project

@HLWeil HLWeil merged commit 8b4368a into main Sep 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ARC RO-Crate profile data model
2 participants