Skip to content

Commit

Permalink
Use enum for directory item types
Browse files Browse the repository at this point in the history
I tried using a class hierarchy to express something similar
(File, ExecutableFile, ...). However, jsonschema has limited
(AKA no) support for inheritance when declaring range classes.
Moreover, the implementation of "DirectoryDirectoryItem" felt
awkward.

This solution feel more similar to the POSIX analog ("all same").
  • Loading branch information
mih committed Nov 28, 2023
1 parent 47778eb commit 92aad76
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/examples/datalad-dataset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ graph:
# # an enum that defines all possible ways directory
# # items could be set up (regular file, symlink,
# # executable, etc).
item_type: file
type: file
#
# content for outputs.txt
- id: MD5E-s4--ba1f2511fc30423bdbb183fe33f3dd0f.txt
Expand Down Expand Up @@ -64,16 +64,16 @@ graph:
items:
.gitmodules:
# content: 144d450caf1e6f93af67973261ac6924fdd3169b
item_type: file
type: file
.datalad:
# content: d3cafe4592eb5837cfd0fc8f4637afc0dd3e7c14
item_type: directory
type: directory
script.py:
# content: af926ef0c359556ac1d36d71f7e173d97b893ff2
item_type: executable_file
type: executable_file
outputs.txt:
# content: MD5E-s4--ba1f2511fc30423bdbb183fe33f3dd0f.txt
item_type: file
type: file
# # annotate availability of the entire tree
# available_at:
# # map storage to storage-specific identifier
Expand Down
20 changes: 15 additions & 5 deletions src/linkml/datalad-datasets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ slots:
Unique identifier.
range: string

enums:
DirectoryItemType:
# TODO add 'meaning' to all these
permissible_values:
file:
executable_file:
directory:
symlink:

classes:
TypedThing:
description: >-
Expand All @@ -38,7 +47,8 @@ classes:
mixins:
- IdentifiedThing
description: >-
File content
File content. More or less an analog of the POSIX filesystem file,
which is also name-less content.
Directory:
is_a: TypedThing
mixins:
Expand All @@ -55,7 +65,8 @@ classes:
inlined_as_list: false
DirectoryItem:
description: >-
An item in a directory
An item in a directory. Assigns a name and other properties to some
content.
attributes:
name:
description: >-
Expand All @@ -64,11 +75,10 @@ classes:
# within a particular context, not globally, but instead here
# within a single directory
identifier: true
item_type:
type:
description:
Identifier of the item type.
# TODO must become an annotated enum
range: string
range: DirectoryItemType


# DataladDataset:
Expand Down

0 comments on commit 92aad76

Please sign in to comment.