Skip to content

feat: implement LinkML exporter#172

Open
ahmdmhd wants to merge 4 commits intoCOVESA:mainfrom
ahmdmhd:feat/export-linkml
Open

feat: implement LinkML exporter#172
ahmdmhd wants to merge 4 commits intoCOVESA:mainfrom
ahmdmhd:feat/export-linkml

Conversation

@ahmdmhd
Copy link
Copy Markdown
Collaborator

@ahmdmhd ahmdmhd commented Mar 9, 2026

This PR is based on #168 and implements LinkML exporter.

s2dm export linkml \
  --schema /path/to/schema \
  --output output.yaml \
  --id schema_id \
  --name schema_name \
  --default-prefix default_prefix \
  --default-prefix-url default_prefix_url

@ahmdmhd ahmdmhd requested a review from jdacoello March 9, 2026 15:48
@ahmdmhd ahmdmhd force-pushed the feat/export-linkml branch from f6559f6 to 86ced57 Compare March 17, 2026 11:38
ahmdmhd added 4 commits March 19, 2026 10:05
Signed-off-by: Ahmed Mohamed <ahmed.mohamed@motius.de>
Signed-off-by: Ahmed Mohamed <ahmed.mohamed@motius.de>
Signed-off-by: Ahmed Mohamed <ahmed.mohamed@motius.de>
Signed-off-by: Ahmed Mohamed <ahmed.mohamed@motius.de>
@ahmdmhd ahmdmhd force-pushed the feat/export-linkml branch from 86ced57 to 04c5d7d Compare March 19, 2026 09:06
Copy link
Copy Markdown
Collaborator

@jdacoello jdacoello left a comment

Choose a reason for hiding this comment

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

Following remarks:

  • Fields that resolve to built-in ID scalar must have identifier: true
type SomeTypeName {
  id: ID!
  ...
}
# Current
SomeTypeName:
  attributes:
    id:
      range: string
      required: true
# Should be
SomeTypeName:
  attributes:
    id:
      range: string
      required: true
      identifier: true
  • Exclude Query and input types
type Query {
  vehicle: Vehicle
}

input KeyValue {
  key: String!
  value: String!
}
  # Currently present
  Query:
    attributes:
      vehicle:
        range: Vehicle

  KeyValue:
    description: Key-value pair for storing metadata.
    attributes:
      key:
        range: string
        required: true
      value:
        range: string
        required: true
  • All top-level concepts should be declared as tree_root: true
type Vehicle {
  ...
}
Vehicle:
  tree_root: true
    ...

Same for other top level concepts. I think we have already a function that returns the top level concepts (i.e., all roots) from a GraphQL schema.

  • Fix handling of units

Right now, the units are passed as seen.

ambientAirTemperature(unit: TemperatureUnitEnum = DEGREE_CELSIUS): Float

enum TemperatureUnitEnum {
  DEGREE_CELSIUS
  DEGREE_FAHRENHEIT
}
temperature:
  range: float
  unit:
    symbol: DEGREE_CELSIUS    # ← enum value name used as-is, no URIs

It seems that the linkml tools expect compatible ones because some tools complain, eg.,:

linkml generate doc <spec-in-linkml.yaml> -d <directory>
TypeError: unhashable type: 'UnitOfMeasure'
  • If custom unit is used, the linkml tools should be able to run (e.g., doc)

When annotation of reference is given, then reflect it, such as:

enum TemperatureUnit @reference(uri: "http://qudt.org/vocab/quantitykind/Temperature") {
  DEG_C @reference(uri: "http://qudt.org/vocab/unit/DEG_C")
  DEG_F @reference(uri: "http://qudt.org/vocab/unit/DEG_F")
}

type SomeType {
  ambientAirTemperature(unit: TemperatureUnit = DEG_C): Float
}
...
TemperatureUnitEnum:
  description: Units for "temperature"
  permissible_values:
    DEG_C:
      meaning: http://qudt.org/vocab/unit/DEG_C
    DEG_F:
      meaning: http://qudt.org/vocab/unit/DEG_F

...
# every attribute that uses unit
ambientAirTemperature:
  range: float
  unit:
    symbol: DEG_C
    exact_mappings:
      - http://qudt.org/vocab/unit/DEG_C

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.

2 participants