ose-plugin-addicto 0.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.4
2
+ Name: ose-plugin-addicto
3
+ Version: 0.2.5
4
+ Summary: OntoSpreadEd plugin for AddictO services and workflows
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: ose-core==0.2.5
8
+ Requires-Dist: ose-plugin-hbcp==0.2.5
9
+
10
+ # OSE Plugin: AddictO
11
+
12
+ OntoSpreadEd plugin for AddictO (Addiction Ontology) services and workflows.
13
+
14
+ ## Description
15
+
16
+ This plugin extends OntoSpreadEd with functionality specific to the AddictO ontology project. It provides:
17
+
18
+ - AddictO vocabulary release step for automated release pipelines
19
+ - Integration with external AddictO vocabulary services
20
+ - Custom UI components for AddictO-specific workflows
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install ose-plugin-addicto
26
+ ```
27
+
28
+ ## Requirements
29
+
30
+ - Python 3.12+
31
+ - ose-core
32
+ - ose-plugin-hbcp
33
+
34
+ ## Configuration
35
+
36
+ The plugin is automatically discovered and loaded when installed. Register it in your release script to use the AddictO vocabulary step.
37
+
38
+ ## License
39
+
40
+ LGPL-3.0-or-later
@@ -0,0 +1,31 @@
1
+ # OSE Plugin: AddictO
2
+
3
+ OntoSpreadEd plugin for AddictO (Addiction Ontology) services and workflows.
4
+
5
+ ## Description
6
+
7
+ This plugin extends OntoSpreadEd with functionality specific to the AddictO ontology project. It provides:
8
+
9
+ - AddictO vocabulary release step for automated release pipelines
10
+ - Integration with external AddictO vocabulary services
11
+ - Custom UI components for AddictO-specific workflows
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install ose-plugin-addicto
17
+ ```
18
+
19
+ ## Requirements
20
+
21
+ - Python 3.12+
22
+ - ose-core
23
+ - ose-plugin-hbcp
24
+
25
+ ## Configuration
26
+
27
+ The plugin is automatically discovered and loaded when installed. Register it in your release script to use the AddictO vocabulary step.
28
+
29
+ ## License
30
+
31
+ LGPL-3.0-or-later
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ose-plugin-addicto"
7
+ version = "0.2.5"
8
+ description = "OntoSpreadEd plugin for AddictO services and workflows"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ dependencies = [
12
+ "ose-core==0.2.5",
13
+ "ose-plugin-hbcp==0.2.5",
14
+ ]
15
+
16
+ [project.entry-points.'ose.plugins']
17
+ addicto = "ose_plugin_addicto:AddictOPlugin"
18
+
19
+ [tool.uv.sources]
20
+ ose-core = { workspace = true }
21
+ ose-plugin-hbcp = { workspace = true }
22
+
23
+ [tool.setuptools.packages.find]
24
+ where = ["src"]
25
+
26
+ [tool.setuptools.package-data]
27
+ ose_plugin_addicto = ["static/*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,58 @@
1
+ from typing import Literal, Dict, Tuple
2
+
3
+ from aiohttp import ClientSession
4
+
5
+ from ose_plugin_hbcp.search_api.APIClient import APIClient
6
+ from ose.model.Term import Term
7
+ from ose.model.TermIdentifier import TermIdentifier
8
+
9
+
10
+ class AddictOVocabClient(APIClient):
11
+ _session: ClientSession
12
+
13
+ _term_link_to_relation_mapping: Dict[
14
+ str, Tuple[TermIdentifier, Literal["single", "multiple", "multiple-per-line"]]] = {
15
+ "synonyms": (TermIdentifier(id="IAO:0000118", label="alternative label"), "multiple"),
16
+ "definition": (TermIdentifier(id="IAO:0000115", label="definition"), "single"),
17
+ "informalDefinition": (TermIdentifier(label="informalDefinition"), "single"),
18
+ "addictoSubOntology": (TermIdentifier(label="lowerLevelOntology"), "multiple"),
19
+ "curatorNote": (TermIdentifier(id="IAO:0000232", label="curator note"), "single"),
20
+ "curationStatus": (TermIdentifier(id="IAO:0000114", label="has curation status"), "single"),
21
+ "comment": (TermIdentifier(id="rdfs:comment", label="rdfs:comment"), "single"),
22
+ "examples": (TermIdentifier(id="IAO:0000112", label="example of usage"), "multiple-per-line"),
23
+ "fuzzySet": (TermIdentifier(label="fuzzySet"), "single"),
24
+ "fuzzyExplanation": (TermIdentifier(label="fuzzyExplanation"), "single"),
25
+ "crossReferences": (TermIdentifier(label="crossReference"), "multiple"),
26
+ }
27
+
28
+ def convert_to_api_term(self, term: Term, with_references=True) -> Dict:
29
+ data = super().convert_to_api_term(term, with_references)
30
+
31
+ if "addictoSubOntology" in data and data["addictoSubOntology"] is not None:
32
+ lower_level_ontologies = [d.lower().strip() for d in data["addictoSubOntology"]]
33
+ if "upper level" in lower_level_ontologies:
34
+ lower_level_ontologies.remove("upper level")
35
+
36
+ data["addictoSubOntology"] = lower_level_ontologies
37
+
38
+ return data
39
+
40
+ async def convert_from_api_term(self, data: Dict, with_references=True) -> Term:
41
+ term = await super().convert_from_api_term(data, with_references)
42
+
43
+ term.relations = [(r, bool(int(v))) if r.id is None and r.label in ["eCigO", "fuzzySet"] else (r, v) for r, v in
44
+ term.relations]
45
+
46
+ return term
47
+
48
+ def terms_equal(self, old: Term, new: Term) -> bool:
49
+ ignore_if_not_exists = [
50
+ "informalDefinition",
51
+ "addictoSubOntology",
52
+ "fuzzySet",
53
+ "fuzzyExplanation",
54
+ "crossReference",
55
+ "eCigO"
56
+ ]
57
+
58
+ return self._terms_equal(ignore_if_not_exists, new, old)
@@ -0,0 +1,78 @@
1
+ import asyncio
2
+ from datetime import datetime
3
+ from typing import List
4
+
5
+ import aiohttp
6
+ from flask_github import GitHub
7
+ from flask_sqlalchemy import SQLAlchemy
8
+
9
+ from ose.model.ExcelOntology import ExcelOntology
10
+ from ose.model.ReleaseScript import ReleaseScript
11
+ from ose.model.Result import Result
12
+ from ose.release.ReleaseStep import ReleaseStep
13
+ from ose.release.common import order_sources
14
+ from .AddictOVocabService import AddictOVocabService
15
+ from ose.services.ConfigurationService import ConfigurationService
16
+
17
+
18
+ class AddictOVocabReleaseStep(ReleaseStep):
19
+ _included_files: List[str]
20
+
21
+ @classmethod
22
+ def name(cls) -> str:
23
+ return "ADDICTO_VOCAB"
24
+
25
+ def __init__(self, db: SQLAlchemy, gh: GitHub, release_script: ReleaseScript, release_id: int, tmp: str,
26
+ config: ConfigurationService, *, included_files: List[str]):
27
+ super().__init__(db, gh, release_script, release_id, tmp, config)
28
+
29
+ self._included_files = included_files
30
+
31
+ def run(self) -> bool:
32
+ result = Result()
33
+ sources = order_sources(
34
+ dict([(k, f) for k, f in self._release_script.files.items() if k in self._included_files]))
35
+
36
+ ontology = ExcelOntology("")
37
+ external_ontology_result = self._load_externals_ontology()
38
+ if not external_ontology_result.ok():
39
+ self._set_release_result(external_ontology_result)
40
+ return False
41
+
42
+ self._raise_if_canceled()
43
+
44
+ external = external_ontology_result.value
45
+
46
+ ontology.import_other_excel_ontology(external)
47
+
48
+ for i, (k, file) in enumerate(sources):
49
+ for s in file.sources:
50
+ if s.type == "classes":
51
+ result += ontology.add_terms_from_excel(s.file, self._local_name(s.file))
52
+ elif s.type == "relations":
53
+ result += ontology.add_relations_from_excel(s.file, self._local_name(s.file))
54
+
55
+ self._raise_if_canceled()
56
+
57
+ ontology.resolve()
58
+ self._raise_if_canceled()
59
+
60
+ ontology.remove_duplicates()
61
+ self._raise_if_canceled()
62
+
63
+ externals = [self._local_name(self._release_script.external.target.file)]
64
+ result += asyncio.run(self.run_service(ontology, externals))
65
+
66
+ self._raise_if_canceled()
67
+
68
+ self._set_release_result(result)
69
+ return result.ok()
70
+
71
+ async def run_service(self, ontology: ExcelOntology, externals: List[str]) -> Result[tuple]:
72
+ async with aiohttp.ClientSession() as session:
73
+ service = AddictOVocabService(self._config, session)
74
+ return await service.update_api(
75
+ ontology,
76
+ externals,
77
+ f"{datetime.utcnow().strftime('%B %Y')} Release",
78
+ lambda step, total, msg: self._update_progress(position=(step, total), current_item=msg))
@@ -0,0 +1,31 @@
1
+ import logging
2
+ import os
3
+
4
+ import aiohttp
5
+
6
+ from ose_plugin_hbcp.search_api.APIService import APIService
7
+ from .AddictOVocabClient import AddictOVocabClient
8
+ from ose.services.ConfigurationService import ConfigurationService
9
+
10
+ PROP_ADDICTO_VOCAB_API_PATH = "ADDICTO_VOCAB_API_PATH"
11
+ PROP_ADDICTO_VOCAB_API_AUTH_TOKEN = "ADDICTO_VOCAB_API_AUTH_TOKEN"
12
+
13
+
14
+ class AddictOVocabService(APIService[AddictOVocabClient]):
15
+ _logger = logging.getLogger(__name__)
16
+
17
+ @property
18
+ def repository_name(self) -> str:
19
+ return "AddictO"
20
+
21
+ def __init__(self, config: ConfigurationService, session: aiohttp.ClientSession):
22
+ path = config.app_config.get(PROP_ADDICTO_VOCAB_API_PATH, os.environ.get(PROP_ADDICTO_VOCAB_API_PATH))
23
+ auth_token = config.app_config.get(
24
+ PROP_ADDICTO_VOCAB_API_AUTH_TOKEN, os.environ.get(PROP_ADDICTO_VOCAB_API_AUTH_TOKEN, None)
25
+ )
26
+
27
+ api_client = AddictOVocabClient(
28
+ path, session, auth_token, config.app_config.get("ENVIRONMENT", "debug") != "production"
29
+ )
30
+
31
+ super().__init__(config, api_client)
@@ -0,0 +1,20 @@
1
+ from ose.model.Plugin import Plugin, PluginComponent
2
+ from .AddictOVocabReleaseStep import AddictOVocabReleaseStep
3
+
4
+
5
+ AddictOPlugin = Plugin(
6
+ id="org.bssofoundry.addicto",
7
+ name="AddictO Plugin",
8
+ version="0.1.0",
9
+ description="Plugin for AddictO services and workflows.",
10
+ contents=[
11
+ AddictOVocabReleaseStep,
12
+ ],
13
+ components=[
14
+ PluginComponent(
15
+ step_name="ADDICTO_VOCAB",
16
+ component_name="AddictOVocab",
17
+ ),
18
+ ],
19
+ js_module="ose-plugin-addicto.js",
20
+ )
@@ -0,0 +1,6 @@
1
+ def main():
2
+ print("Hello from addicto!")
3
+
4
+
5
+ if __name__ == "__main__":
6
+ main()
@@ -0,0 +1,39 @@
1
+ import { defineComponent as r, createElementBlock as a, openBlock as e, Fragment as o, createElementVNode as s, createBlock as d, createCommentVNode as c, renderList as u, toDisplayString as n, unref as h, withCtx as m, createTextVNode as p } from "vue";
2
+ import { ProgressIndicator as g } from "@ose/js-core";
3
+ const b = { class: "alert alert-danger" }, y = { key: 1 }, k = { key: 2 }, O = /* @__PURE__ */ r({
4
+ __name: "AddictOVocab",
5
+ props: {
6
+ data: {},
7
+ release: {},
8
+ selectedSubStep: {}
9
+ },
10
+ emits: ["release-control"],
11
+ setup(t) {
12
+ return (f, i) => (e(), a(o, null, [
13
+ i[1] || (i[1] = s("h3", null, "Publishing the release", -1)),
14
+ t.release.state === "waiting-for-user" && t.data?.errors?.length > 0 ? (e(!0), a(o, { key: 0 }, u(t.data.errors, (l) => (e(), a("div", b, [
15
+ l.details && l?.response?.["hydra:description"] ? (e(), a(o, { key: 0 }, [
16
+ s("h4", null, n(l.response["hydra:title"]), 1),
17
+ s("p", null, n(l.details), 1),
18
+ s("p", null, n(l.response["hydra:description"]), 1)
19
+ ], 64)) : (e(), a("pre", y, n(JSON.stringify(l, void 0, 2)), 1))
20
+ ]))), 256)) : (e(), d(h(g), {
21
+ key: 1,
22
+ details: t.data,
23
+ release: t.release
24
+ }, {
25
+ default: m(() => [...i[0] || (i[0] = [
26
+ s("p", null, [
27
+ p(" The ontologies are being published to AddictOVocab. This will take a while."),
28
+ s("br")
29
+ ], -1)
30
+ ])]),
31
+ _: 1
32
+ }, 8, ["details", "release"])),
33
+ t.release.state === "completed" ? (e(), a("p", k, " The ontologies were published to AddictOVocab. ")) : c("", !0)
34
+ ], 64));
35
+ }
36
+ });
37
+ export {
38
+ O as AddictOVocab
39
+ };
@@ -0,0 +1 @@
1
+ (function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@ose/js-core")):typeof define=="function"&&define.amd?define(["exports","vue","@ose/js-core"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.ose_plugin_addicto={},t.Vue,t.OseJsCore))})(this,(function(t,e,i){"use strict";const s={class:"alert alert-danger"},r={key:1},a={key:2},d=e.defineComponent({__name:"AddictOVocab",props:{data:{},release:{},selectedSubStep:{}},emits:["release-control"],setup(n){return(c,l)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[l[1]||(l[1]=e.createElementVNode("h3",null,"Publishing the release",-1)),n.release.state==="waiting-for-user"&&n.data?.errors?.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(n.data.errors,o=>(e.openBlock(),e.createElementBlock("div",s,[o.details&&o?.response?.["hydra:description"]?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("h4",null,e.toDisplayString(o.response["hydra:title"]),1),e.createElementVNode("p",null,e.toDisplayString(o.details),1),e.createElementVNode("p",null,e.toDisplayString(o.response["hydra:description"]),1)],64)):(e.openBlock(),e.createElementBlock("pre",r,e.toDisplayString(JSON.stringify(o,void 0,2)),1))]))),256)):(e.openBlock(),e.createBlock(e.unref(i.ProgressIndicator),{key:1,details:n.data,release:n.release},{default:e.withCtx(()=>[...l[0]||(l[0]=[e.createElementVNode("p",null,[e.createTextVNode(" The ontologies are being published to AddictOVocab. This will take a while."),e.createElementVNode("br")],-1)])]),_:1},8,["details","release"])),n.release.state==="completed"?(e.openBlock(),e.createElementBlock("p",a," The ontologies were published to AddictOVocab. ")):e.createCommentVNode("",!0)],64))}});t.AddictOVocab=d,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.4
2
+ Name: ose-plugin-addicto
3
+ Version: 0.2.5
4
+ Summary: OntoSpreadEd plugin for AddictO services and workflows
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: ose-core==0.2.5
8
+ Requires-Dist: ose-plugin-hbcp==0.2.5
9
+
10
+ # OSE Plugin: AddictO
11
+
12
+ OntoSpreadEd plugin for AddictO (Addiction Ontology) services and workflows.
13
+
14
+ ## Description
15
+
16
+ This plugin extends OntoSpreadEd with functionality specific to the AddictO ontology project. It provides:
17
+
18
+ - AddictO vocabulary release step for automated release pipelines
19
+ - Integration with external AddictO vocabulary services
20
+ - Custom UI components for AddictO-specific workflows
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install ose-plugin-addicto
26
+ ```
27
+
28
+ ## Requirements
29
+
30
+ - Python 3.12+
31
+ - ose-core
32
+ - ose-plugin-hbcp
33
+
34
+ ## Configuration
35
+
36
+ The plugin is automatically discovered and loaded when installed. Register it in your release script to use the AddictO vocabulary step.
37
+
38
+ ## License
39
+
40
+ LGPL-3.0-or-later
@@ -0,0 +1,15 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/ose_plugin_addicto/AddictOVocabClient.py
4
+ src/ose_plugin_addicto/AddictOVocabReleaseStep.py
5
+ src/ose_plugin_addicto/AddictOVocabService.py
6
+ src/ose_plugin_addicto/__init__.py
7
+ src/ose_plugin_addicto/main.py
8
+ src/ose_plugin_addicto.egg-info/PKG-INFO
9
+ src/ose_plugin_addicto.egg-info/SOURCES.txt
10
+ src/ose_plugin_addicto.egg-info/dependency_links.txt
11
+ src/ose_plugin_addicto.egg-info/entry_points.txt
12
+ src/ose_plugin_addicto.egg-info/requires.txt
13
+ src/ose_plugin_addicto.egg-info/top_level.txt
14
+ src/ose_plugin_addicto/static/ose-plugin-addicto.js
15
+ src/ose_plugin_addicto/static/ose-plugin-addicto.umd.cjs
@@ -0,0 +1,2 @@
1
+ [ose.plugins]
2
+ addicto = ose_plugin_addicto:AddictOPlugin
@@ -0,0 +1,2 @@
1
+ ose-core==0.2.5
2
+ ose-plugin-hbcp==0.2.5
@@ -0,0 +1,2 @@
1
+ ose-plugin-addicto-js
2
+ ose_plugin_addicto