Skip to content

Commit

Permalink
chore: fix linting issues & general cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
makkus committed Mar 26, 2024
1 parent eb49c3a commit 4f029dc
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 30 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ exclude = [
"dist",
"node_modules",
"venv",
"examples/"
"examples/",
"dev/"
]

# Assume Python 3.10.
Expand Down
1 change: 0 additions & 1 deletion src/kiara/context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from kiara.data_types import DataType
from kiara.exceptions import KiaraContextException
from kiara.interfaces import get_console
from kiara.interfaces.python_api.base_api import BaseAPI
from kiara.interfaces.python_api.models.info import (
DataTypeClassesInfo,
InfoItemGroup,
Expand Down
1 change: 1 addition & 0 deletions src/kiara/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
CHUNK_CACHE_DIR_DEPTH = 2
CHUNK_CACHE_DIR_WIDTH = 1


class SpecialValue(Enum):

NOT_SET = "__not_set__"
Expand Down
2 changes: 1 addition & 1 deletion src/kiara/interfaces/cli/type/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def explain_data_type(ctx, type_name: str, format: str):
"""Print details of a data type."""

from kiara.interfaces.python_api.models.info import DataTypeClassInfo

kiara_obj: Kiara = ctx.obj.kiara

data_type = kiara_obj.type_registry.retrieve_data_type(
Expand Down
3 changes: 1 addition & 2 deletions src/kiara/interfaces/python_api/base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2199,8 +2199,7 @@ def export_values(
)

if export_related_metadata:
print("TODO: Export related metadata.")
# raise NotImplementedError("xx")
raise NotImplementedError("Exporting related metadata not implemented yet.")

if additional_archive_metadata:
for k, v in additional_archive_metadata.items():
Expand Down
1 change: 0 additions & 1 deletion src/kiara/interfaces/python_api/kiara_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import uuid
from collections.abc import Iterable, Mapping
from pathlib import Path

# BEGIN AUTO-GENERATED-IMPORTS
Expand Down
1 change: 0 additions & 1 deletion src/kiara/interfaces/python_api/models/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from kiara.defaults import CHUNK_COMPRESSION_TYPE
from kiara.models import KiaraModel
from kiara.registries.jobs import JobArchive

if TYPE_CHECKING:
from kiara.context import Kiara
Expand Down
10 changes: 4 additions & 6 deletions src/kiara/interfaces/python_api/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,10 @@ def api_endpint_names(self) -> List[str]:

temp = []

avail_methods = [
member
for member in inspect.getmembers(
self._api_cls, predicate=inspect.isfunction
)
]
avail_methods = list(
inspect.getmembers(self._api_cls, predicate=inspect.isfunction)
)

avail_methods.sort(key=lambda x: inspect.getsourcelines(x[1])[1])

method_names = [x[0] for x in avail_methods]
Expand Down
2 changes: 0 additions & 2 deletions src/kiara/models/values/value_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,3 @@ def _retrieve_id(self) -> str:

def _retrieve_data_to_hash(self) -> Any:
return {"metadata": self.model_dump(), "schema": self.schema_json()}


7 changes: 5 additions & 2 deletions src/kiara/renderers/included_renderers/api/base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
from typing import (
TYPE_CHECKING,
Any,
Dict,
Iterable,
Mapping,
Union, Dict, Set,
Set,
Union,
)

from pydantic.fields import Field
Expand Down Expand Up @@ -323,6 +325,7 @@ def _render(
target_file = Path(render_config.target_file)
target_file.parent.mkdir(parents=True, exist_ok=True)
target_file.write_text(new_content)
print(f"Rendered api to file '{target_file}'.")
terminal_print()
terminal_print(f"Rendered api to file '{target_file}'.")
else:
return new_content
7 changes: 5 additions & 2 deletions src/kiara/utils/archives.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# -*- coding: utf-8 -*-
from functools import lru_cache
from typing import Union, Dict, TYPE_CHECKING
from typing import TYPE_CHECKING, Dict, Union

if TYPE_CHECKING:
from kiara.context import Kiara
from kiara.interfaces.python_api.models.info import TypeInfo
from kiara.models.archives import ArchiveTypeClassesInfo


@lru_cache(maxsize=None)
def find_archive_types(
alias: Union[str, None] = None, only_for_package: Union[str, None] = None
) -> "ArchiveTypeClassesInfo":

from kiara.utils.class_loading import find_all_archive_types
from kiara.models.archives import ArchiveTypeClassesInfo
from kiara.utils.class_loading import find_all_archive_types

archive_types = find_all_archive_types()

Expand Down
3 changes: 1 addition & 2 deletions src/kiara/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import os
from pathlib import Path
from typing import Any, TYPE_CHECKING, Dict
from typing import TYPE_CHECKING, Any, Dict

import orjson

Expand Down Expand Up @@ -42,7 +42,6 @@ def orm_json_deserialize(obj: str) -> Any:
return orjson.loads(obj)



def create_archive_engine(
db_path: Path, force_read_only: bool, use_wal_mode: bool
) -> "Engine":
Expand Down
2 changes: 1 addition & 1 deletion src/kiara/utils/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def create_signature_string(

def extract_arg_names(func: Callable) -> typing.List[str]:
sig = inspect.signature(func)
return [name for name in sig.parameters.keys()]
return list(sig.parameters.keys())


def extract_proxy_arg_str(func: Callable) -> str:
Expand Down
23 changes: 15 additions & 8 deletions src/kiara/utils/metadata.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# -*- coding: utf-8 -*-
from functools import lru_cache

# Copyright (c) 2021, University of Luxembourg / DHARPA project
# Copyright (c) 2021, Markus Binsteiner
#
# Mozilla Public License, version 2.0 (see LICENSE or https://www.mozilla.org/en-US/MPL/2.0/)

from typing import Dict, Type, Union, Mapping, TYPE_CHECKING
from typing import TYPE_CHECKING, Dict, Type, Union

from kiara.models.values.value_metadata import ValueMetadata
from kiara.registries.models import ModelRegistry

if TYPE_CHECKING:
from kiara.context import Kiara
from kiara.interfaces.python_api.models.info import MetadataTypeClassesInfo, MetadataTypeInfo
from kiara.interfaces.python_api.models.info import (
MetadataTypeClassesInfo,
)


@lru_cache()
Expand Down Expand Up @@ -45,7 +47,9 @@ def find_metadata_models(
return group


def get_metadata_model_for_data_type(kiara: "Kiara", data_type: str) -> "MetadataTypeClassesInfo":
def get_metadata_model_for_data_type(
kiara: "Kiara", data_type: str
) -> "MetadataTypeClassesInfo":
"""
Return all available metadata extract operations for the provided type (and it's parent types).
Expand All @@ -60,9 +64,8 @@ def get_metadata_model_for_data_type(kiara: "Kiara", data_type: str) -> "Metadat

from kiara.interfaces.python_api.models.info import MetadataTypeClassesInfo

lineage = set(
kiara.type_registry.get_type_lineage(data_type_name=data_type)
)
# TODO: add models for parent types?
# lineage = set(kiara.type_registry.get_type_lineage(data_type_name=data_type))

model_registry = ModelRegistry.instance()
all_metadata_models = model_registry.get_models_of_type(ValueMetadata)
Expand All @@ -76,6 +79,10 @@ def get_metadata_model_for_data_type(kiara: "Kiara", data_type: str) -> "Metadat
if data_type in supported:
matching_types[name] = metadata_cls

result: MetadataTypeClassesInfo = MetadataTypeClassesInfo.create_from_type_items(kiara=kiara, group_title=f"Metadata models for type '{data_type}'", **matching_types)
result: MetadataTypeClassesInfo = MetadataTypeClassesInfo.create_from_type_items(
kiara=kiara,
group_title=f"Metadata models for type '{data_type}'",
**matching_types,
)

return result

0 comments on commit 4f029dc

Please sign in to comment.