ose-plugin-addicto 0.2.5__py3-none-any.whl
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.
- ose_plugin_addicto/AddictOVocabClient.py +58 -0
- ose_plugin_addicto/AddictOVocabReleaseStep.py +78 -0
- ose_plugin_addicto/AddictOVocabService.py +31 -0
- ose_plugin_addicto/__init__.py +20 -0
- ose_plugin_addicto/main.py +6 -0
- ose_plugin_addicto/static/ose-plugin-addicto.js +39 -0
- ose_plugin_addicto/static/ose-plugin-addicto.umd.cjs +1 -0
- ose_plugin_addicto-0.2.5.dist-info/METADATA +40 -0
- ose_plugin_addicto-0.2.5.dist-info/RECORD +12 -0
- ose_plugin_addicto-0.2.5.dist-info/WHEEL +5 -0
- ose_plugin_addicto-0.2.5.dist-info/entry_points.txt +2 -0
- ose_plugin_addicto-0.2.5.dist-info/top_level.txt +1 -0
|
@@ -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,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,12 @@
|
|
|
1
|
+
ose_plugin_addicto/AddictOVocabClient.py,sha256=q7QOdssY0ldX_DQubEJljBfi9-JYeA4rHytG3o-RX3o,2607
|
|
2
|
+
ose_plugin_addicto/AddictOVocabReleaseStep.py,sha256=avYbCFiA3365vrmS7rriGeaC-eyykcW6pr2dt2k0Mlg,2821
|
|
3
|
+
ose_plugin_addicto/AddictOVocabService.py,sha256=uVqtDsilIc335gW0pR99bpQkVT4KgTSc1rq3wldoW8k,1083
|
|
4
|
+
ose_plugin_addicto/__init__.py,sha256=beWSaKyNq48XXqiF9mAjUZMyFQvaFVdHAZfn1DJb6L4,522
|
|
5
|
+
ose_plugin_addicto/main.py,sha256=s66rWqSfEmyTRIb-hvGBuVBN5VXpSDYeXfzOjENcnLU,85
|
|
6
|
+
ose_plugin_addicto/static/ose-plugin-addicto.js,sha256=rTPLk5cKRqUrrF1l7Ppg1dExf2zYQ1ikvf_XZ1Y0X5k,1678
|
|
7
|
+
ose_plugin_addicto/static/ose-plugin-addicto.umd.cjs,sha256=1kAMmpF2AxgpGujAJjBkxMHJpMMay6EkW1LcnL7OsVg,1848
|
|
8
|
+
ose_plugin_addicto-0.2.5.dist-info/METADATA,sha256=vhlPjOe55-xvG2cW308SUPPj9xsrmosiGJUPkLM1EKQ,971
|
|
9
|
+
ose_plugin_addicto-0.2.5.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
10
|
+
ose_plugin_addicto-0.2.5.dist-info/entry_points.txt,sha256=yZ0mEHZ1B8dYTjjLrSMjXN4KlkaOLc-1Tn36Bk5zzhw,57
|
|
11
|
+
ose_plugin_addicto-0.2.5.dist-info/top_level.txt,sha256=e-YtOH03Ac8OgWqL7dv9rjC2ZRjaV2NGgyjXYJ9qVn4,19
|
|
12
|
+
ose_plugin_addicto-0.2.5.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ose_plugin_addicto
|