Skip to content

Commit

Permalink
Made semsimian an optional dependency (#704)
Browse files Browse the repository at this point in the history
* Made semsimian an optional dependency

* latest version of semsimian

* Address semsimian being optional dependency

* formatted

* updated message

* formatted

* Use TYPE_CHECKING

* roll back init

* formatted

* add sesmimian as dependency in tox

* duplicate

* add semsimian install

* add semsimian install

* edit semsimian install

* undo semsimian install

* fixed semsimian mystery

* semsimian as a group not an extra

* optional semsimian possible solution

* formatted

* formatted

* formatted

* updated gitignore

* corrected branch diff madness

* don't initialize it to be None

* formatted

* Should fix the gh action error thanks @justaddcoffee

* update pip dependency

* cleanup+formatted

* semsimian as extra not group

* formatted

* formatted

* formatted

* formatted
  • Loading branch information
hrshdhgd authored Mar 14, 2024
1 parent b94123b commit 8b9e6a3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction --extras "gilda"
run: poetry install --no-interaction --extras "gilda semsimian"

- name: Get Gilda resources
run: |
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ kgcl-schema = "^0.6.5"

funowl = ">=0.2.0"
gilda = {version = ">=1.0.0", optional = true}
semsimian = {version = ">=0.1.0", optional = true}
kgcl-rdflib = "0.5.0"
llm = {version = "*", optional = true}
aiohttp = {version = "*", optional = true}
Expand All @@ -37,7 +38,6 @@ pysolr = "^3.9.0"
eutils = ">=0.6.0"
requests-cache = "^1.0.1"
click = "*"
semsimian = "^0.2.1"
urllib3 = {version = "< 2", optional = true}
pydantic = "*"
jsonlines = "^4.0.0"
Expand Down Expand Up @@ -75,6 +75,7 @@ docs = ["Sphinx", "sphinx-rtd-theme", "sphinxcontrib-mermaid", "sphinx-copybutto
gilda = ["scipy", "gilda", "urllib3"]
llm = ["llm", "aiohttp"]
seaborn = ["seaborn"]
semsimian = ["semsimian"]

[tool.black]
line-length = 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from dataclasses import dataclass, field
from typing import ClassVar, Dict, Iterable, Iterator, List, Optional, Tuple, Union

from semsimian import Semsimian

from oaklib.datamodels.similarity import (
BestMatch,
TermInfo,
Expand Down Expand Up @@ -51,7 +49,7 @@ class SemSimianImplementation(SearchInterface, SemanticSimilarityInterface, OboG
SemanticSimilarityInterface.information_content_scores,
]

semsimian_object_cache: Dict[Tuple[PRED_CURIE], Semsimian] = field(default_factory=dict)
semsimian_object_cache: Dict[Tuple[PRED_CURIE], Optional["Semsimian"]] = field(default_factory=dict) # type: ignore # noqa

def __post_init__(self):
slug = self.resource.slug
Expand Down Expand Up @@ -81,13 +79,15 @@ def _get_semsimian_object(
predicates: List[PRED_CURIE] = None,
attributes: List[str] = None,
resource_path: str = None,
) -> Semsimian:
) -> "Semsimian": # type: ignore # noqa
"""
Get Semsimian object from "semsimian_object_cache" or add a new one.
:param predicates: collection of predicates, defaults to None
:return: A Semsimian object.
"""
from semsimian import Semsimian

predicates = tuple(sorted(predicates))
if predicates not in self.semsimian_object_cache:
# spo = [
Expand Down

0 comments on commit 8b9e6a3

Please sign in to comment.