SOLI Configuration Module#
This module contains the configuration utilities for the SOLI (Standard for Open Legal Information) Python library.
Configuration Constants#
DEFAULT_CONFIG_PATH: Path to the default configuration file.DEFAULT_GITHUB_API_URL: Default GitHub API URL.DEFAULT_GITHUB_OBJECT_URL: Default GitHub raw content URL.DEFAULT_SOURCE_TYPE: Default source type for loading the ontology.DEFAULT_HTTP_URL: Default HTTP URL for the ontology.DEFAULT_GITHUB_REPO_OWNER: Default GitHub repository owner.DEFAULT_GITHUB_REPO_NAME: Default GitHub repository name.DEFAULT_GITHUB_REPO_BRANCH: Default GitHub repository branch.
SOLI Configuration#
A Pydantic model representing the configuration for the SOLI Python library.
Attributes#
source: The source of the SOLI configuration. Must be either ‘github’ or ‘http’.url: The URL of the SOLI configuration if source is ‘http’.repo_owner: The owner of the GitHub repository if source is ‘github’.repo_name: The name of the GitHub repository if source is ‘github’.branch: The branch of the GitHub repository if source is ‘github’.path: The path to the SOLI.owl file in the repository or URL.use_cache: Whether to use caching for the SOLI configuration.
Methods#
load_config(config_path: str | Path = DEFAULT_CONFIG_PATH) -> SOLIConfiguration#
Load the configuration from a JSON file.
Args: config_path (str | Path): The path to the configuration file.
Returns: SOLIConfiguration: The loaded configuration object.
Raises: FileNotFoundError: If the configuration file is not found.
Example:
config = SOLIConfiguration.load_config()
print(config.source)
print(config.repo_owner)
Usage#
To use the SOLI configuration in your project:
Create a JSON configuration file (default location:
~/.soli/config.json) with the following structure:
{
"soli": {
"source": "github",
"repo_owner": "alea-institute",
"repo_name": "soli",
"branch": "1.0.0",
"path": "SOLI.owl",
"use_cache": true
}
}
In your Python code, import and use the SOLIConfiguration class:
from soli.config import SOLIConfiguration
# Load the configuration
config = SOLIConfiguration.load_config()
# Access configuration values
print(f"Source: {config.source}")
print(f"Repository: {config.repo_owner}/{config.repo_name}")
print(f"Branch: {config.branch}")
This module provides a flexible way to configure the SOLI Python library, allowing users to specify custom sources and paths for the SOLI ontology.
Module Contents#
Configuration for the SOLI (Standard for Open Legal Information) Python library.
- class soli.config.SOLIConfiguration(*, source: Literal['github', 'http'], url: str | None = None, repo_owner: str | None = None, repo_name: str | None = None, branch: str | None = None, path: str | None = None, use_cache: bool = True)#
Configuration for the SOLI (Standard for Open Legal Information) Python library.
- static load_config(config_path: str | Path = PosixPath('/home/docs/.soli/config.json')) SOLIConfiguration#
Load the configuration from a JSON file.
- Args:
config_path (str | Path): The path to the configuration file.
- Returns:
dict: The configuration dictionary.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'json_schema_extra': {'examples': [{'soli': {'branch': '1.0.0', 'path': 'SOLI.owl', 'repo_name': 'soli', 'repo_owner': 'alea-institute/', 'source': 'github', 'use_cache': True}}]}}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'branch': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, description="The branch of the GitHub repository if source is 'github'."), 'path': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, description='The path to the SOLI.owl file in the repository or URL.'), 'repo_name': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, description="The name of the GitHub repository if source is 'github'."), 'repo_owner': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, description="The owner of the GitHub repository if source is 'github'."), 'source': FieldInfo(annotation=Literal['github', 'http'], required=True, description="The source of the SOLI configuration. Must be either 'github' or 'http'."), 'url': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, description="The URL of the SOLI configuration if source is 'http'."), 'use_cache': FieldInfo(annotation=bool, required=False, default=True, description='Whether to use caching for the SOLI configuration.')}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.