DRS applications

Contents

DRS applications#

Validation#

class esgvoc.apps.drs.validator.DrsApplication(project_id: str, pedantic: bool = False)[source]#

Bases: object

Generic DRS application class.

dataset_id_specs: DrsSpecification[source]#

The DRS dataset id specs of the project.

directory_specs: DrsSpecification[source]#

The DRS directory specs of the project.

file_name_specs: DrsSpecification[source]#

The DRS file name specs of the project.

pedantic: bool[source]#

Same as the option of GCC: turn warnings into errors. Default False.

project_id: str[source]#

The project id.

class esgvoc.apps.drs.validator.DrsValidator(project_id: str, pedantic: bool = False)[source]#

Bases: DrsApplication

Valid a DRS directory, dataset id and file name expression against a project.

validate(drs_expression: str, drs_type: DrsType | str) DrsValidationReport[source]#

Validate a DRS expression.

Parameters:
  • drs_expression (str) – A DRS expression.

  • drs_type (DrsType|str) – The type of the given DRS expression (directory, file_name or dataset_id)

Returns:

A validation report.

Return type:

DrsValidationReport

validate_dataset_id(drs_expression: str) DrsValidationReport[source]#

Validate a DRS dataset id expression.

Parameters:

drs_expression (str) – A DRS dataset id expression.

Returns:

A validation report.

Return type:

DrsValidationReport

validate_directory(drs_expression: str, prefix: str | None = None) DrsValidationReport[source]#

Validate a DRS directory expression.

Parameters:
  • drs_expression (str) – A DRS directory expression.

  • prefix (str|None) – A directory prefix to be removed from the directory expression.

Returns:

A validation report.

Return type:

DrsValidationReport

validate_file_name(drs_expression: str) DrsValidationReport[source]#

Validate a file name expression.

Parameters:

drs_expression (str) – A DRS file name expression.

Returns:

A validation report.

Return type:

DrsValidationReport

dataset_id_specs: DrsSpecification[source]#

The DRS dataset id specs of the project.

directory_specs: DrsSpecification[source]#

The DRS directory specs of the project.

file_name_specs: DrsSpecification[source]#

The DRS file name specs of the project.

pedantic: bool[source]#

Same as the option of GCC: turn warnings into errors. Default False.

project_id: str[source]#

The project id.

Generation#

class esgvoc.apps.drs.generator.DrsGenerator(project_id: str, pedantic: bool = False)[source]#

Bases: DrsApplication

Generate a directory, dataset id and file name expression specified by the given project from a mapping of collection ids and terms or an unordered bag of terms.

generate_dataset_id_from_bag_of_terms(terms: Iterable[str]) DrsGenerationReport[source]#

Generate a dataset id DRS expression from an unordered bag of terms.

Parameters:

terms (Iterable[str]) – An unordered bag of terms.

Returns:

A generation report.

Return type:

DrsGeneratorReport

generate_dataset_id_from_mapping(mapping: Mapping[str, str]) DrsGenerationReport[source]#

Generate a dataset id DRS expression from a mapping of collection ids and terms.

Parameters:

mapping (Mapping[str, str]) – A mapping of collection ids (keys) and terms (values).

Returns:

A generation report.

Return type:

DrsGeneratorReport

generate_directory_from_bag_of_terms(terms: Iterable[str]) DrsGenerationReport[source]#

Generate a directory DRS expression from an unordered bag of terms.

Parameters:

terms (Iterable[str]) – An unordered bag of terms.

Returns:

A generation report.

Return type:

DrsGeneratorReport

generate_directory_from_mapping(mapping: Mapping[str, str]) DrsGenerationReport[source]#

Generate a directory DRS expression from a mapping of collection ids and terms.

Parameters:

mapping (Mapping[str, str]) – A mapping of collection ids (keys) and terms (values).

Returns:

A generation report.

Return type:

DrsGeneratorReport

generate_file_name_from_bag_of_terms(terms: Iterable[str]) DrsGenerationReport[source]#

Generate a file name DRS expression from an unordered bag of terms. The file name extension is append automatically, according to the DRS specification, so none of the terms given must include the extension.

Parameters:

terms (Iterable[str]) – An unordered bag of terms.

Returns:

A generation report.

Return type:

DrsGeneratorReport

generate_file_name_from_mapping(mapping: Mapping[str, str]) DrsGenerationReport[source]#

Generate a file name DRS expression from a mapping of collection ids and terms. The file name extension is append automatically, according to the DRS specification, so none of the terms given must include the extension.

Parameters:

mapping (Mapping[str, str]) – A mapping of collection ids (keys) and terms (values).

Returns:

A generation report.

Return type:

DrsGeneratorReport

generate_from_bag_of_terms(terms: Iterable[str], drs_type: DrsType | str) DrsGenerationReport[source]#

Generate a DRS expression from an unordered bag of terms.

Parameters:
  • terms (Iterable[str]) – An unordered bag of terms.

  • drs_type (DrsType|str) – The type of the given DRS expression (directory, file_name or dataset_id)

Returns:

A generation report.

Return type:

DrsGeneratorReport

generate_from_mapping(mapping: Mapping[str, str], drs_type: DrsType | str) DrsGenerationReport[source]#

Generate a DRS expression from a mapping of collection ids and terms.

Parameters:
  • mapping (Mapping[str, str]) – A mapping of collection ids (keys) and terms (values).

  • drs_type (DrsType|str) – The type of the given DRS expression (directory, file_name or dataset_id)

Returns:

A generation report.

Return type:

DrsGeneratorReport

dataset_id_specs: DrsSpecification[source]#

The DRS dataset id specs of the project.

directory_specs: DrsSpecification[source]#

The DRS directory specs of the project.

file_name_specs: DrsSpecification[source]#

The DRS file name specs of the project.

pedantic: bool[source]#

Same as the option of GCC: turn warnings into errors. Default False.

project_id: str[source]#

The project id.

Issue reporting#

Pydantic model esgvoc.apps.drs.report.AssignedTerm[source]#

Bases: GenerationIssue

Represents a decision of the Generator to assign this term to the collection, that may not be. relevant.

Show JSON schema
{
   "title": "AssignedTerm",
   "description": "Represents a decision of the Generator to assign this term to the collection, that may not be.\nrelevant.",
   "type": "object",
   "properties": {
      "kind": {
         "const": "AssignedTerm",
         "default": "AssignedTerm",
         "title": "Kind",
         "type": "string"
      },
      "collection_id": {
         "title": "Collection Id",
         "type": "string"
      },
      "term": {
         "title": "Term",
         "type": "string"
      }
   },
   "required": [
      "collection_id",
      "term"
   ]
}

field collection_id: str [Required][source]#

The collection id.

field kind: Literal[IssueKind.ASSIGNED] = IssueKind.ASSIGNED[source]#

The class name of the issue for JSON serialization/deserialization.

field term: str [Required][source]#

The term.

accept(visitor: GenerationIssueVisitor) Any[source]#

Accept an DRS generation issue visitor.

Parameters:

visitor (GenerationIssueVisitor) – The DRS generation issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

Pydantic model esgvoc.apps.drs.report.BlankTerm[source]#

Bases: ParsingIssue

Represents a problem of blank term in the DRS expression (i.e., space[s] surrounded by separators).

Show JSON schema
{
   "title": "BlankTerm",
   "description": "Represents a problem of blank term in the DRS expression (i.e., space[s] surrounded by separators).",
   "type": "object",
   "properties": {
      "kind": {
         "const": "BlankTerm",
         "default": "BlankTerm",
         "title": "Kind",
         "type": "string"
      },
      "column": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Column"
      }
   }
}

field column: int | None = None[source]#

the column of faulty characters.

field kind: Literal[IssueKind.BLANK_TERM] = IssueKind.BLANK_TERM[source]#

The class name of the issue for JSON serialization/deserialization.

accept(visitor: ParsingIssueVisitor) Any[source]#

Accept an DRS parsing issue visitor.

Parameters:

visitor (ParsingIssueVisitor) – The DRS parsing issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

Pydantic model esgvoc.apps.drs.report.ComplianceIssue[source]#

Bases: DrsIssue

Generic class for the compliance issues.

Show JSON schema
{
   "title": "ComplianceIssue",
   "description": "Generic class for the compliance issues.",
   "type": "object",
   "properties": {
      "kind": {
         "title": "Kind",
         "type": "string"
      }
   },
   "required": [
      "kind"
   ]
}

field kind: str [Required][source]#

The class name of the issue for JSON serialization/deserialization.

abstractmethod accept(visitor: ComplianceIssueVisitor) Any[source]#

Accept an DRS compliance issue visitor.

Parameters:

visitor (ComplianceIssueVisitor) – The DRS compliance issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

class esgvoc.apps.drs.report.ComplianceIssueVisitor(*args, **kwargs)[source]#

Bases: Protocol

Specifications for a compliance issues visitor.

visit_extra_term_issue(issue: ExtraTerm) Any[source]#

Visit an extra term issue.

visit_filename_extension_issue(issue: FileNameExtensionIssue) Any[source]#

Visit a file name extension issue.

visit_invalid_term_issue(issue: InvalidTerm) Any[source]#

Visit an invalid term issue.

visit_missing_term_issue(issue: MissingTerm) Any[source]#

Visit a missing term issue.

Pydantic model esgvoc.apps.drs.report.ConflictingCollections[source]#

Bases: GenerationIssue

Represents a problem while inferring a mapping collection - term in the generation of a DRS expression based on a bag of terms. The problem is that these collections shares the very same terms. The generator is unable to choose which term for which collection.

Show JSON schema
{
   "title": "ConflictingCollections",
   "description": "Represents a problem while inferring a mapping collection - term in the generation\nof a DRS expression based on a bag of terms. The problem is that these collections shares the\nvery same terms. The generator is unable to choose which term for which collection.",
   "type": "object",
   "properties": {
      "kind": {
         "const": "ConflictingCollections",
         "default": "ConflictingCollections",
         "title": "Kind",
         "type": "string"
      },
      "collection_ids": {
         "items": {
            "type": "string"
         },
         "title": "Collection Ids",
         "type": "array"
      },
      "terms": {
         "items": {
            "type": "string"
         },
         "title": "Terms",
         "type": "array"
      }
   },
   "required": [
      "collection_ids",
      "terms"
   ]
}

field collection_ids: list[str] [Required][source]#

The ids of the collections.

field kind: Literal[IssueKind.CONFLICT] = IssueKind.CONFLICT[source]#

The class name of the issue for JSON serialization/deserialization.

field terms: list[str] [Required][source]#

The shared terms.

accept(visitor: GenerationIssueVisitor) Any[source]#

Accept an DRS generation issue visitor.

Parameters:

visitor (GenerationIssueVisitor) – The DRS generation issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

Pydantic model esgvoc.apps.drs.report.DrsGenerationReport[source]#

Bases: DrsReport

The DRS generation report.

Show JSON schema
{
   "title": "DrsGenerationReport",
   "description": "The DRS generation report.",
   "type": "object",
   "properties": {
      "project_id": {
         "title": "Project Id",
         "type": "string"
      },
      "type": {
         "$ref": "#/$defs/DrsType"
      },
      "errors": {
         "items": {
            "discriminator": {
               "mapping": {
                  "AssignedTerm": "#/$defs/AssignedTerm",
                  "ConflictingCollections": "#/$defs/ConflictingCollections",
                  "InvalidTerm": "#/$defs/InvalidTerm",
                  "MissingTerm": "#/$defs/MissingTerm",
                  "TooManyTermsCollection": "#/$defs/TooManyTermCollection"
               },
               "propertyName": "kind"
            },
            "oneOf": [
               {
                  "$ref": "#/$defs/AssignedTerm"
               },
               {
                  "$ref": "#/$defs/ConflictingCollections"
               },
               {
                  "$ref": "#/$defs/InvalidTerm"
               },
               {
                  "$ref": "#/$defs/MissingTerm"
               },
               {
                  "$ref": "#/$defs/TooManyTermCollection"
               }
            ]
         },
         "title": "Errors",
         "type": "array"
      },
      "warnings": {
         "items": {
            "discriminator": {
               "mapping": {
                  "AssignedTerm": "#/$defs/AssignedTerm",
                  "MissingTerm": "#/$defs/MissingTerm"
               },
               "propertyName": "kind"
            },
            "oneOf": [
               {
                  "$ref": "#/$defs/AssignedTerm"
               },
               {
                  "$ref": "#/$defs/MissingTerm"
               }
            ]
         },
         "title": "Warnings",
         "type": "array"
      },
      "given_mapping_or_bag_of_terms": {
         "anyOf": [
            {
               "additionalProperties": true,
               "type": "object"
            },
            {
               "items": {},
               "type": "array"
            }
         ],
         "title": "Given Mapping Or Bag Of Terms"
      },
      "mapping_used": {
         "additionalProperties": true,
         "title": "Mapping Used",
         "type": "object"
      },
      "generated_drs_expression": {
         "title": "Generated Drs Expression",
         "type": "string"
      }
   },
   "$defs": {
      "AssignedTerm": {
         "description": "Represents a decision of the Generator to assign this term to the collection, that may not be.\nrelevant.",
         "properties": {
            "kind": {
               "const": "AssignedTerm",
               "default": "AssignedTerm",
               "title": "Kind",
               "type": "string"
            },
            "collection_id": {
               "title": "Collection Id",
               "type": "string"
            },
            "term": {
               "title": "Term",
               "type": "string"
            }
         },
         "required": [
            "collection_id",
            "term"
         ],
         "title": "AssignedTerm",
         "type": "object"
      },
      "ConflictingCollections": {
         "description": "Represents a problem while inferring a mapping collection - term in the generation\nof a DRS expression based on a bag of terms. The problem is that these collections shares the\nvery same terms. The generator is unable to choose which term for which collection.",
         "properties": {
            "kind": {
               "const": "ConflictingCollections",
               "default": "ConflictingCollections",
               "title": "Kind",
               "type": "string"
            },
            "collection_ids": {
               "items": {
                  "type": "string"
               },
               "title": "Collection Ids",
               "type": "array"
            },
            "terms": {
               "items": {
                  "type": "string"
               },
               "title": "Terms",
               "type": "array"
            }
         },
         "required": [
            "collection_ids",
            "terms"
         ],
         "title": "ConflictingCollections",
         "type": "object"
      },
      "DrsType": {
         "description": "The types of DRS specification (directory, file name and dataset id).",
         "enum": [
            "directory",
            "file_name",
            "dataset_id"
         ],
         "title": "DrsType",
         "type": "string"
      },
      "InvalidTerm": {
         "description": "Represents a problem of invalid term against a collection or a constant part of a DRS specification.",
         "properties": {
            "kind": {
               "const": "InvalidTerm",
               "default": "InvalidTerm",
               "title": "Kind",
               "type": "string"
            },
            "term": {
               "title": "Term",
               "type": "string"
            },
            "term_position": {
               "title": "Term Position",
               "type": "integer"
            },
            "collection_id_or_constant_value": {
               "title": "Collection Id Or Constant Value",
               "type": "string"
            }
         },
         "required": [
            "term",
            "term_position",
            "collection_id_or_constant_value"
         ],
         "title": "InvalidTerm",
         "type": "object"
      },
      "MissingTerm": {
         "description": "Represents a problem of missing term for a collection part of the DRS specification.",
         "properties": {
            "kind": {
               "const": "MissingTerm",
               "default": "MissingTerm",
               "title": "Kind",
               "type": "string"
            },
            "collection_id": {
               "title": "Collection Id",
               "type": "string"
            },
            "collection_position": {
               "title": "Collection Position",
               "type": "integer"
            }
         },
         "required": [
            "collection_id",
            "collection_position"
         ],
         "title": "MissingTerm",
         "type": "object"
      },
      "TooManyTermCollection": {
         "description": "Represents a problem while inferring a mapping collection - term in the generation\nof a DRS expression based on a bag of terms. The problem is that more than one term\nis able to match this collection. The generator is unable to choose from these terms",
         "properties": {
            "kind": {
               "const": "TooManyTermsCollection",
               "default": "TooManyTermsCollection",
               "title": "Kind",
               "type": "string"
            },
            "collection_id": {
               "title": "Collection Id",
               "type": "string"
            },
            "terms": {
               "items": {
                  "type": "string"
               },
               "title": "Terms",
               "type": "array"
            }
         },
         "required": [
            "collection_id",
            "terms"
         ],
         "title": "TooManyTermCollection",
         "type": "object"
      }
   },
   "required": [
      "project_id",
      "type",
      "errors",
      "warnings",
      "given_mapping_or_bag_of_terms",
      "mapping_used",
      "generated_drs_expression"
   ]
}

field errors: list[Annotated[AssignedTerm | ConflictingCollections | InvalidTerm | MissingTerm | TooManyTermCollection, FieldInfo(annotation=NoneType, required=True, discriminator='kind')]] [Required][source]#

A list of DRS generation issues that are considered as errors.

field generated_drs_expression: str [Required][source]#

The generated DRS expression with possible tags to replace missing or invalid terms.

field given_mapping_or_bag_of_terms: Mapping | Iterable [Required][source]#

The mapping or the bag of terms given.

field mapping_used: Mapping [Required][source]#

The mapping inferred from the given bag of terms (same mapping otherwise).

field project_id: str [Required][source]#

The project id associated to the result of the DRS application.

field type: DrsType [Required][source]#

The type of the DRS

field warnings: list[Annotated[AssignedTerm | MissingTerm, FieldInfo(annotation=NoneType, required=True, discriminator='kind')]] [Required][source]#

A list of DRS generation issues that are considered as warnings.

INVALID_TAG: ClassVar[str] = '[INVALID]'[source]#

Tag used in the DRS generated expression to replace a invalid term.

MISSING_TAG: ClassVar[str] = '[MISSING]'[source]#

Tag used in the DRS generated expression to replace a missing term.

property nb_errors: int[source]#

The number of errors.

property nb_warnings: int[source]#

The number of warnings.

property validated: bool[source]#

The correctness of the result of the DRS application.

Pydantic model esgvoc.apps.drs.report.DrsIssue[source]#

Bases: BaseModel, ABC

Show JSON schema
{
   "title": "DrsIssue",
   "type": "object",
   "properties": {
      "kind": {
         "title": "Kind",
         "type": "string"
      }
   },
   "required": [
      "kind"
   ]
}

field kind: str [Required][source]#

The class name of the issue for JSON serialization/deserialization.

abstractmethod accept(visitor) Any[source]#

Accept an DRS issue visitor.

Parameters:

visitor – The DRS issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

Pydantic model esgvoc.apps.drs.report.DrsReport[source]#

Bases: BaseModel

Generic DRS application report class.

Show JSON schema
{
   "title": "DrsReport",
   "description": "Generic DRS application report class.",
   "type": "object",
   "properties": {
      "project_id": {
         "title": "Project Id",
         "type": "string"
      },
      "type": {
         "$ref": "#/$defs/DrsType"
      },
      "errors": {
         "items": {},
         "title": "Errors",
         "type": "array"
      },
      "warnings": {
         "items": {},
         "title": "Warnings",
         "type": "array"
      }
   },
   "$defs": {
      "DrsType": {
         "description": "The types of DRS specification (directory, file name and dataset id).",
         "enum": [
            "directory",
            "file_name",
            "dataset_id"
         ],
         "title": "DrsType",
         "type": "string"
      }
   },
   "required": [
      "project_id",
      "type",
      "errors",
      "warnings"
   ]
}

field errors: list [Required][source]#

A list of DRS issues that are considered as errors.

field project_id: str [Required][source]#

The project id associated to the result of the DRS application.

field type: DrsType [Required][source]#

The type of the DRS

field warnings: list [Required][source]#

A list of DRS issues that are considered as warnings.

property nb_errors: int[source]#

The number of errors.

property nb_warnings: int[source]#

The number of warnings.

property validated: bool[source]#

The correctness of the result of the DRS application.

Pydantic model esgvoc.apps.drs.report.DrsValidationReport[source]#

Bases: DrsReport

The DRS validation report class.

Show JSON schema
{
   "title": "DrsValidationReport",
   "description": "The DRS validation report class.",
   "type": "object",
   "properties": {
      "project_id": {
         "title": "Project Id",
         "type": "string"
      },
      "type": {
         "$ref": "#/$defs/DrsType"
      },
      "errors": {
         "items": {
            "discriminator": {
               "mapping": {
                  "BlankTerm": "#/$defs/BlankTerm",
                  "ExtraChar": "#/$defs/ExtraChar",
                  "ExtraSeparator": "#/$defs/ExtraSeparator",
                  "ExtraTerm": "#/$defs/ExtraTerm",
                  "FileNameExtensionIssue": "#/$defs/FileNameExtensionIssue",
                  "InvalidTerm": "#/$defs/InvalidTerm",
                  "MissingTerm": "#/$defs/MissingTerm",
                  "Space": "#/$defs/Space",
                  "Unparsable": "#/$defs/Unparsable"
               },
               "propertyName": "kind"
            },
            "oneOf": [
               {
                  "$ref": "#/$defs/BlankTerm"
               },
               {
                  "$ref": "#/$defs/ExtraChar"
               },
               {
                  "$ref": "#/$defs/ExtraSeparator"
               },
               {
                  "$ref": "#/$defs/ExtraTerm"
               },
               {
                  "$ref": "#/$defs/FileNameExtensionIssue"
               },
               {
                  "$ref": "#/$defs/InvalidTerm"
               },
               {
                  "$ref": "#/$defs/MissingTerm"
               },
               {
                  "$ref": "#/$defs/Space"
               },
               {
                  "$ref": "#/$defs/Unparsable"
               }
            ]
         },
         "title": "Errors",
         "type": "array"
      },
      "warnings": {
         "items": {
            "discriminator": {
               "mapping": {
                  "ExtraSeparator": "#/$defs/ExtraSeparator",
                  "MissingTerm": "#/$defs/MissingTerm",
                  "Space": "#/$defs/Space"
               },
               "propertyName": "kind"
            },
            "oneOf": [
               {
                  "$ref": "#/$defs/ExtraSeparator"
               },
               {
                  "$ref": "#/$defs/MissingTerm"
               },
               {
                  "$ref": "#/$defs/Space"
               }
            ]
         },
         "title": "Warnings",
         "type": "array"
      },
      "expression": {
         "title": "Expression",
         "type": "string"
      }
   },
   "$defs": {
      "BlankTerm": {
         "description": "Represents a problem of blank term in the DRS expression (i.e., space[s] surrounded by separators).",
         "properties": {
            "kind": {
               "const": "BlankTerm",
               "default": "BlankTerm",
               "title": "Kind",
               "type": "string"
            },
            "column": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Column"
            }
         },
         "title": "BlankTerm",
         "type": "object"
      },
      "DrsType": {
         "description": "The types of DRS specification (directory, file name and dataset id).",
         "enum": [
            "directory",
            "file_name",
            "dataset_id"
         ],
         "title": "DrsType",
         "type": "string"
      },
      "ExtraChar": {
         "description": "Represents a problem of extra characters at the end of the DRS expression.",
         "properties": {
            "kind": {
               "const": "ExtraChar",
               "default": "ExtraChar",
               "title": "Kind",
               "type": "string"
            },
            "column": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Column"
            }
         },
         "title": "ExtraChar",
         "type": "object"
      },
      "ExtraSeparator": {
         "description": "Represents a problem of multiple separator occurrences in the DRS expression.",
         "properties": {
            "kind": {
               "const": "ExtraSeparator",
               "default": "ExtraSeparator",
               "title": "Kind",
               "type": "string"
            },
            "column": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Column"
            }
         },
         "title": "ExtraSeparator",
         "type": "object"
      },
      "ExtraTerm": {
         "description": "Represents a problem of extra term at the end of the given DRS expression.\nAll part of the DRS specification have been processed and this term is not necessary\n(`collection_id` is `None`) or it has been invalidated by an optional collection part\nof the DRS specification (`collection_id` is set).",
         "properties": {
            "kind": {
               "const": "ExtraTerm",
               "default": "ExtraTerm",
               "title": "Kind",
               "type": "string"
            },
            "term": {
               "title": "Term",
               "type": "string"
            },
            "term_position": {
               "title": "Term Position",
               "type": "integer"
            },
            "collection_id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "title": "Collection Id"
            }
         },
         "required": [
            "term",
            "term_position",
            "collection_id"
         ],
         "title": "ExtraTerm",
         "type": "object"
      },
      "FileNameExtensionIssue": {
         "description": "Represents a problem on the given file name extension (missing or not compliant).",
         "properties": {
            "kind": {
               "const": "FileNameExtensionIssue",
               "default": "FileNameExtensionIssue",
               "title": "Kind",
               "type": "string"
            },
            "expected_extension": {
               "title": "Expected Extension",
               "type": "string"
            }
         },
         "required": [
            "expected_extension"
         ],
         "title": "FileNameExtensionIssue",
         "type": "object"
      },
      "InvalidTerm": {
         "description": "Represents a problem of invalid term against a collection or a constant part of a DRS specification.",
         "properties": {
            "kind": {
               "const": "InvalidTerm",
               "default": "InvalidTerm",
               "title": "Kind",
               "type": "string"
            },
            "term": {
               "title": "Term",
               "type": "string"
            },
            "term_position": {
               "title": "Term Position",
               "type": "integer"
            },
            "collection_id_or_constant_value": {
               "title": "Collection Id Or Constant Value",
               "type": "string"
            }
         },
         "required": [
            "term",
            "term_position",
            "collection_id_or_constant_value"
         ],
         "title": "InvalidTerm",
         "type": "object"
      },
      "MissingTerm": {
         "description": "Represents a problem of missing term for a collection part of the DRS specification.",
         "properties": {
            "kind": {
               "const": "MissingTerm",
               "default": "MissingTerm",
               "title": "Kind",
               "type": "string"
            },
            "collection_id": {
               "title": "Collection Id",
               "type": "string"
            },
            "collection_position": {
               "title": "Collection Position",
               "type": "integer"
            }
         },
         "required": [
            "collection_id",
            "collection_position"
         ],
         "title": "MissingTerm",
         "type": "object"
      },
      "Space": {
         "description": "Represents a problem of unnecessary space[s] at the beginning or end of the DRS expression.\nNote: `column` is `None`.",
         "properties": {
            "kind": {
               "const": "Space",
               "default": "Space",
               "title": "Kind",
               "type": "string"
            },
            "column": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Column"
            }
         },
         "title": "Space",
         "type": "object"
      },
      "Unparsable": {
         "description": "Represents a problem of non-compliance of the DRS expression.\nNote: `column` is `None`.",
         "properties": {
            "kind": {
               "const": "Unparsable",
               "default": "Unparsable",
               "title": "Kind",
               "type": "string"
            },
            "column": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Column"
            },
            "expected_drs_type": {
               "$ref": "#/$defs/DrsType"
            }
         },
         "required": [
            "expected_drs_type"
         ],
         "title": "Unparsable",
         "type": "object"
      }
   },
   "required": [
      "project_id",
      "type",
      "errors",
      "warnings",
      "expression"
   ]
}

field errors: list[Annotated[BlankTerm | ExtraChar | ExtraSeparator | ExtraTerm | FileNameExtensionIssue | InvalidTerm | MissingTerm | Space | Unparsable, FieldInfo(annotation=NoneType, required=True, discriminator='kind')]] [Required][source]#

A list of DRS parsing and compliance issues that are considered as errors.

field expression: str [Required][source]#

The DRS expression been checked.

field project_id: str [Required][source]#

The project id associated to the result of the DRS application.

field type: DrsType [Required][source]#

The type of the DRS

field warnings: list[Annotated[ExtraSeparator | MissingTerm | Space, FieldInfo(annotation=NoneType, required=True, discriminator='kind')]] [Required][source]#

A list of DRS parsing and compliance issues that are considered as warnings.

property nb_errors: int[source]#

The number of errors.

property nb_warnings: int[source]#

The number of warnings.

property validated: bool[source]#

The correctness of the result of the DRS application.

Pydantic model esgvoc.apps.drs.report.ExtraChar[source]#

Bases: ParsingIssue

Represents a problem of extra characters at the end of the DRS expression.

Show JSON schema
{
   "title": "ExtraChar",
   "description": "Represents a problem of extra characters at the end of the DRS expression.",
   "type": "object",
   "properties": {
      "kind": {
         "const": "ExtraChar",
         "default": "ExtraChar",
         "title": "Kind",
         "type": "string"
      },
      "column": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Column"
      }
   }
}

field column: int | None = None[source]#

the column of faulty characters.

field kind: Literal[IssueKind.EXTRA_CHAR] = IssueKind.EXTRA_CHAR[source]#

The class name of the issue for JSON serialization/deserialization.

accept(visitor: ParsingIssueVisitor) Any[source]#

Accept an DRS parsing issue visitor.

Parameters:

visitor (ParsingIssueVisitor) – The DRS parsing issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

Pydantic model esgvoc.apps.drs.report.ExtraSeparator[source]#

Bases: ParsingIssue

Represents a problem of multiple separator occurrences in the DRS expression.

Show JSON schema
{
   "title": "ExtraSeparator",
   "description": "Represents a problem of multiple separator occurrences in the DRS expression.",
   "type": "object",
   "properties": {
      "kind": {
         "const": "ExtraSeparator",
         "default": "ExtraSeparator",
         "title": "Kind",
         "type": "string"
      },
      "column": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Column"
      }
   }
}

field column: int | None = None[source]#

the column of faulty characters.

field kind: Literal[IssueKind.EXTRA_SEPARATOR] = IssueKind.EXTRA_SEPARATOR[source]#

The class name of the issue for JSON serialization/deserialization.

accept(visitor: ParsingIssueVisitor) Any[source]#

Accept an DRS parsing issue visitor.

Parameters:

visitor (ParsingIssueVisitor) – The DRS parsing issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

Pydantic model esgvoc.apps.drs.report.ExtraTerm[source]#

Bases: TermIssue

Represents a problem of extra term at the end of the given DRS expression. All part of the DRS specification have been processed and this term is not necessary (collection_id is None) or it has been invalidated by an optional collection part of the DRS specification (collection_id is set).

Show JSON schema
{
   "title": "ExtraTerm",
   "description": "Represents a problem of extra term at the end of the given DRS expression.\nAll part of the DRS specification have been processed and this term is not necessary\n(`collection_id` is `None`) or it has been invalidated by an optional collection part\nof the DRS specification (`collection_id` is set).",
   "type": "object",
   "properties": {
      "kind": {
         "const": "ExtraTerm",
         "default": "ExtraTerm",
         "title": "Kind",
         "type": "string"
      },
      "term": {
         "title": "Term",
         "type": "string"
      },
      "term_position": {
         "title": "Term Position",
         "type": "integer"
      },
      "collection_id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "title": "Collection Id"
      }
   },
   "required": [
      "term",
      "term_position",
      "collection_id"
   ]
}

field collection_id: str | None [Required][source]#

The optional collection id or None.

field kind: Literal[IssueKind.EXTRA_TERM] = IssueKind.EXTRA_TERM[source]#

The class name of the issue for JSON serialization/deserialization.

field term: str [Required][source]#

The faulty term.

field term_position: int [Required][source]#

The position of the faulty term (the part position, not the column of the characters.

accept(visitor: ComplianceIssueVisitor) Any[source]#

Accept an DRS compliance issue visitor.

Parameters:

visitor (ComplianceIssueVisitor) – The DRS compliance issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

Pydantic model esgvoc.apps.drs.report.FileNameExtensionIssue[source]#

Bases: ComplianceIssue

Represents a problem on the given file name extension (missing or not compliant).

Show JSON schema
{
   "title": "FileNameExtensionIssue",
   "description": "Represents a problem on the given file name extension (missing or not compliant).",
   "type": "object",
   "properties": {
      "kind": {
         "const": "FileNameExtensionIssue",
         "default": "FileNameExtensionIssue",
         "title": "Kind",
         "type": "string"
      },
      "expected_extension": {
         "title": "Expected Extension",
         "type": "string"
      }
   },
   "required": [
      "expected_extension"
   ]
}

field expected_extension: str [Required][source]#

The expected file name extension.

field kind: Literal[IssueKind.FILE_NAME] = IssueKind.FILE_NAME[source]#

The class name of the issue for JSON serialization/deserialization.

accept(visitor: ComplianceIssueVisitor) Any[source]#

Accept an DRS compliance issue visitor.

Parameters:

visitor (ComplianceIssueVisitor) – The DRS compliance issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

Pydantic model esgvoc.apps.drs.report.GenerationIssue[source]#

Bases: DrsIssue

Generic class for the DRS generation issues.

Show JSON schema
{
   "title": "GenerationIssue",
   "description": "Generic class for the DRS generation issues.",
   "type": "object",
   "properties": {
      "kind": {
         "title": "Kind",
         "type": "string"
      }
   },
   "required": [
      "kind"
   ]
}

field kind: str [Required][source]#

The class name of the issue for JSON serialization/deserialization.

abstractmethod accept(visitor: GenerationIssueVisitor) Any[source]#

Accept an DRS generation issue visitor.

Parameters:

visitor (GenerationIssueVisitor) – The DRS generation issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

class esgvoc.apps.drs.report.GenerationIssueVisitor(*args, **kwargs)[source]#

Bases: Protocol

Specifications for a generator issues visitor.

visit_assign_term_issue(issue: AssignedTerm) Any[source]#

Visit an assign term issue.

visit_conflicting_collections_issue(issue: ConflictingCollections) Any[source]#

Visit a conflicting collections issue.

visit_invalid_term_issue(issue: InvalidTerm) Any[source]#

Visit an invalid term issue.

visit_missing_term_issue(issue: MissingTerm) Any[source]#

Visit a missing term issue.

visit_too_many_terms_collection_issue(issue: TooManyTermCollection) Any[source]#

Visit a too many terms collection issue.

Pydantic model esgvoc.apps.drs.report.InvalidTerm[source]#

Bases: TermIssue, GenerationIssue

Represents a problem of invalid term against a collection or a constant part of a DRS specification.

Show JSON schema
{
   "title": "InvalidTerm",
   "description": "Represents a problem of invalid term against a collection or a constant part of a DRS specification.",
   "type": "object",
   "properties": {
      "kind": {
         "const": "InvalidTerm",
         "default": "InvalidTerm",
         "title": "Kind",
         "type": "string"
      },
      "term": {
         "title": "Term",
         "type": "string"
      },
      "term_position": {
         "title": "Term Position",
         "type": "integer"
      },
      "collection_id_or_constant_value": {
         "title": "Collection Id Or Constant Value",
         "type": "string"
      }
   },
   "required": [
      "term",
      "term_position",
      "collection_id_or_constant_value"
   ]
}

field collection_id_or_constant_value: str [Required][source]#

The collection id or the constant part of a DRS specification.

field kind: Literal[IssueKind.INVALID_TERM] = IssueKind.INVALID_TERM[source]#

The class name of the issue for JSON serialization/deserialization.

field term: str [Required][source]#

The faulty term.

field term_position: int [Required][source]#

The position of the faulty term (the part position, not the column of the characters.

accept(visitor: ComplianceIssueVisitor | GenerationIssueVisitor) Any[source]#

Accept an DRS compliance issue visitor.

Parameters:

visitor (ComplianceIssueVisitor) – The DRS compliance issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

class esgvoc.apps.drs.report.IssueKind(*values)[source]#

Bases: str, Enum

The kinds of validation and generation issues.

ASSIGNED = 'AssignedTerm'[source]#

Represents a decision of the Generator to assign a term to a collection, that may not be.

BLANK_TERM = 'BlankTerm'[source]#

Represents a problem of blank term in the DRS expression (i.e., space[s] surrounded by separators).

CONFLICT = 'ConflictingCollections'[source]#

Represents a problem while inferring a mapping: collections shares the very same terms

EXTRA_CHAR = 'ExtraChar'[source]#

Represents a problem of extra characters at the end of the DRS expression.

EXTRA_SEPARATOR = 'ExtraSeparator'[source]#

Represents a problem of multiple separator occurrences in the DRS expression.

EXTRA_TERM = 'ExtraTerm'[source]#

Represents a problem of extra term at the end of the given DRS expression.

FILE_NAME = 'FileNameExtensionIssue'[source]#

Represents a problem on the given file name extension (missing or not compliant).

INVALID_TERM = 'InvalidTerm'[source]#

Represents a problem of invalid term against a collection or a constant part of a DRS specification.

MISSING_TERM = 'MissingTerm'[source]#

Represents a problem of missing term for a collection part of the DRS specification.

SPACE = 'Space'[source]#

Represents a problem of unnecessary space[s] at the beginning or end of the DRS expression.

TOO_MANY = 'TooManyTermsCollection'[source]#

Represents a problem while inferring a mapping: one term is able to match a collection

UNPARSABLE = 'Unparsable'[source]#

Represents a problem of non-compliance of the DRS expression.

Pydantic model esgvoc.apps.drs.report.MissingTerm[source]#

Bases: ComplianceIssue, GenerationIssue

Represents a problem of missing term for a collection part of the DRS specification.

Show JSON schema
{
   "title": "MissingTerm",
   "description": "Represents a problem of missing term for a collection part of the DRS specification.",
   "type": "object",
   "properties": {
      "kind": {
         "const": "MissingTerm",
         "default": "MissingTerm",
         "title": "Kind",
         "type": "string"
      },
      "collection_id": {
         "title": "Collection Id",
         "type": "string"
      },
      "collection_position": {
         "title": "Collection Position",
         "type": "integer"
      }
   },
   "required": [
      "collection_id",
      "collection_position"
   ]
}

field collection_id: str [Required][source]#

The collection id.

field collection_position: int [Required][source]#

The collection part position (not the column of the characters).

field kind: Literal[IssueKind.MISSING_TERM] = IssueKind.MISSING_TERM[source]#

The class name of the issue for JSON serialization/deserialization.

accept(visitor: ComplianceIssueVisitor | GenerationIssueVisitor) Any[source]#

Accept an DRS compliance issue visitor.

Parameters:

visitor (ComplianceIssueVisitor) – The DRS compliance issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

Pydantic model esgvoc.apps.drs.report.ParsingIssue[source]#

Bases: DrsIssue

Generic class for the DRS parsing issues.

Show JSON schema
{
   "title": "ParsingIssue",
   "description": "Generic class for the DRS parsing issues.",
   "type": "object",
   "properties": {
      "kind": {
         "title": "Kind",
         "type": "string"
      },
      "column": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Column"
      }
   },
   "required": [
      "kind"
   ]
}

field column: int | None = None[source]#

the column of faulty characters.

field kind: str [Required][source]#

The class name of the issue for JSON serialization/deserialization.

abstractmethod accept(visitor: ParsingIssueVisitor) Any[source]#

Accept an DRS parsing issue visitor.

Parameters:

visitor (ParsingIssueVisitor) – The DRS parsing issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

class esgvoc.apps.drs.report.ParsingIssueVisitor(*args, **kwargs)[source]#

Bases: Protocol

Specifications for a parsing issues visitor.

visit_blank_term_issue(issue: BlankTerm) Any[source]#

Visit a blank term issue.

visit_extra_char_issue(issue: ExtraChar) Any[source]#

Visit an extra char issue.

visit_extra_separator_issue(issue: ExtraSeparator) Any[source]#

Visit an extra separator issue.

visit_space_issue(issue: Space) Any[source]#

Visit a space issue.

visit_unparsable_issue(issue: Unparsable) Any[source]#

Visit a unparsable issue.

Pydantic model esgvoc.apps.drs.report.Space[source]#

Bases: ParsingIssue

Represents a problem of unnecessary space[s] at the beginning or end of the DRS expression. Note: column is None.

Show JSON schema
{
   "title": "Space",
   "description": "Represents a problem of unnecessary space[s] at the beginning or end of the DRS expression.\nNote: `column` is `None`.",
   "type": "object",
   "properties": {
      "kind": {
         "const": "Space",
         "default": "Space",
         "title": "Kind",
         "type": "string"
      },
      "column": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Column"
      }
   }
}

field column: int | None = None[source]#

the column of faulty characters.

field kind: Literal[IssueKind.SPACE] = IssueKind.SPACE[source]#

The class name of the issue for JSON serialization/deserialization.

accept(visitor: ParsingIssueVisitor) Any[source]#

Accept an DRS parsing issue visitor.

Parameters:

visitor (ParsingIssueVisitor) – The DRS parsing issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

Pydantic model esgvoc.apps.drs.report.TermIssue[source]#

Bases: ComplianceIssue

Generic class for the DRS term issues.

Show JSON schema
{
   "title": "TermIssue",
   "description": "Generic class for the DRS term issues.",
   "type": "object",
   "properties": {
      "kind": {
         "title": "Kind",
         "type": "string"
      },
      "term": {
         "title": "Term",
         "type": "string"
      },
      "term_position": {
         "title": "Term Position",
         "type": "integer"
      }
   },
   "required": [
      "kind",
      "term",
      "term_position"
   ]
}

field kind: str [Required][source]#

The class name of the issue for JSON serialization/deserialization.

field term: str [Required][source]#

The faulty term.

field term_position: int [Required][source]#

The position of the faulty term (the part position, not the column of the characters.

abstractmethod accept(visitor: ComplianceIssueVisitor) Any[source]#

Accept an DRS compliance issue visitor.

Parameters:

visitor (ComplianceIssueVisitor) – The DRS compliance issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

Pydantic model esgvoc.apps.drs.report.TooManyTermCollection[source]#

Bases: GenerationIssue

Represents a problem while inferring a mapping collection - term in the generation of a DRS expression based on a bag of terms. The problem is that more than one term is able to match this collection. The generator is unable to choose from these terms

Show JSON schema
{
   "title": "TooManyTermCollection",
   "description": "Represents a problem while inferring a mapping collection - term in the generation\nof a DRS expression based on a bag of terms. The problem is that more than one term\nis able to match this collection. The generator is unable to choose from these terms",
   "type": "object",
   "properties": {
      "kind": {
         "const": "TooManyTermsCollection",
         "default": "TooManyTermsCollection",
         "title": "Kind",
         "type": "string"
      },
      "collection_id": {
         "title": "Collection Id",
         "type": "string"
      },
      "terms": {
         "items": {
            "type": "string"
         },
         "title": "Terms",
         "type": "array"
      }
   },
   "required": [
      "collection_id",
      "terms"
   ]
}

field collection_id: str [Required][source]#

The collection id.

field kind: Literal[IssueKind.TOO_MANY] = IssueKind.TOO_MANY[source]#

The class name of the issue for JSON serialization/deserialization.

field terms: list[str] [Required][source]#

The faulty terms.

accept(visitor: GenerationIssueVisitor) Any[source]#

Accept an DRS generation issue visitor.

Parameters:

visitor (GenerationIssueVisitor) – The DRS generation issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

Pydantic model esgvoc.apps.drs.report.Unparsable[source]#

Bases: ParsingIssue

Represents a problem of non-compliance of the DRS expression. Note: column is None.

Show JSON schema
{
   "title": "Unparsable",
   "description": "Represents a problem of non-compliance of the DRS expression.\nNote: `column` is `None`.",
   "type": "object",
   "properties": {
      "kind": {
         "const": "Unparsable",
         "default": "Unparsable",
         "title": "Kind",
         "type": "string"
      },
      "column": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Column"
      },
      "expected_drs_type": {
         "$ref": "#/$defs/DrsType"
      }
   },
   "$defs": {
      "DrsType": {
         "description": "The types of DRS specification (directory, file name and dataset id).",
         "enum": [
            "directory",
            "file_name",
            "dataset_id"
         ],
         "title": "DrsType",
         "type": "string"
      }
   },
   "required": [
      "expected_drs_type"
   ]
}

field column: int | None = None[source]#

the column of faulty characters.

field expected_drs_type: DrsType [Required][source]#

The expected DRS type of the expression (directory, file name or dataset id).

field kind: Literal[IssueKind.UNPARSABLE] = IssueKind.UNPARSABLE[source]#

The class name of the issue for JSON serialization/deserialization.

accept(visitor: ParsingIssueVisitor) Any[source]#

Accept an DRS parsing issue visitor.

Parameters:

visitor (ParsingIssueVisitor) – The DRS parsing issue visitor.

Returns:

Depending on the visitor.

Return type:

Any

class esgvoc.apps.drs.report.ValidationIssueVisitor(*args, **kwargs)[source]#

Bases: ParsingIssueVisitor, ComplianceIssueVisitor

visit_blank_term_issue(issue: BlankTerm) Any[source]#

Visit a blank term issue.

visit_extra_char_issue(issue: ExtraChar) Any[source]#

Visit an extra char issue.

visit_extra_separator_issue(issue: ExtraSeparator) Any[source]#

Visit an extra separator issue.

visit_extra_term_issue(issue: ExtraTerm) Any[source]#

Visit an extra term issue.

visit_filename_extension_issue(issue: FileNameExtensionIssue) Any[source]#

Visit a file name extension issue.

visit_invalid_term_issue(issue: InvalidTerm) Any[source]#

Visit an invalid term issue.

visit_missing_term_issue(issue: MissingTerm) Any[source]#

Visit a missing term issue.

visit_space_issue(issue: Space) Any[source]#

Visit a space issue.

visit_unparsable_issue(issue: Unparsable) Any[source]#

Visit a unparsable issue.