Skip to content

Commit 5c760d4

Browse files
committed
Update bg2cellml to version 0.11.2; fetching metadata about generated CellML needs to be asynchronous.
1 parent 355bb1e commit 5c760d4

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
"./networkx-3.5-py3-none-any.whl": "./dist/networkx-3.5-py3-none-any.whl",
8282
"./sympy-1.14.0-py3-none-any.whl": "./dist/sympy-1.14.0-py3-none-any.whl",
8383
"./flexcache-0.3-py3-none-any.whl": "./dist/flexcache-0.3-py3-none-any.whl",
84+
"./bg2cellml-0.11.2-py3-none-any.whl": "./dist/bg2cellml-0.11.2-py3-none-any.whl",
8485
"./lark-1.3.1-py3-none-any.whl": "./dist/lark-1.3.1-py3-none-any.whl",
85-
"./bg2cellml-0.11.0-py3-none-any.whl": "./dist/bg2cellml-0.10.2-py3-none-any.whl",
8686
"./platformdirs-4.5.0-py3-none-any.whl": "./dist/platformdirs-4.5.0-py3-none-any.whl",
8787
"./typing_extensions-4.15.0-py3-none-any.whl": "./dist/typing_extensions-4.15.0-py3-none-any.whl",
8888
"./ucumvert-0.3.0-py3-none-any.whl": "./dist/ucumvert-0.3.0-py3-none-any.whl",

src/bg2cellml/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export type RdfInterface = {
8585
getRdfStatements: () => Statement[]
8686
}
8787

88-
function status(msg: string, statusMsg: ((msg:string) => void)|undefined) {
88+
function status(msg: string, statusMsg: ((msg:string) => void)|undefined=undefined) {
8989
if (statusMsg) {
9090
statusMsg(msg)
9191
}
@@ -129,7 +129,7 @@ export async function initialisePython(pyodideApi: PyodideAPI, rdfInterface: Rdf
129129
const RUN_BG2CELLML = `
130130
from pyodide.ffi import to_js
131131
132-
def bg2cellml(uri: str, bg_rdf: str, metatata: bool=False, debug: bool=False):
132+
async def bg2cellml(uri: str, bg_rdf: str, metatata: bool=False, debug: bool=False):
133133
try:
134134
bgrdf_model = framework.make_bondgraph_model(uri, bg_rdf, debug=debug)
135135
if bgrdf_model.has_issues:
@@ -138,7 +138,7 @@ def bg2cellml(uri: str, bg_rdf: str, metatata: bool=False, debug: bool=False):
138138
cellml_model = bgrdf_model.make_cellml_model()
139139
result = { 'cellml': cellml_model.to_xml() }
140140
if metatata:
141-
result['metatata'] = cellml_model.metadata(uri)
141+
result['metatata'] = await cellml_model.metadata(uri)
142142
return to_js(result)
143143
except Exception as e:
144144
return to_js({
@@ -149,21 +149,21 @@ bg2cellml
149149

150150
//==============================================================================
151151

152-
function bg2cellml(uri: string, bgRdf: string, options: CellMLGenerationOptions|undefined=undefined): CellMLOutput {
152+
async function bg2cellml(uri: string, bgRdf: string, options: CellMLGenerationOptions|undefined=undefined): Promise<CellMLOutput> {
153153
if (pyodide) {
154154
const bg2cellml = pyodide.runPython(RUN_BG2CELLML)
155-
return bg2cellml(uri, bgRdf, options?.metadata, options?.debug) // options
155+
return await bg2cellml(uri, bgRdf, options?.metadata, options?.debug) // options
156156
}
157157
return {
158158
issues: ['CellML conversion service has not been initialised']
159159
}
160160
}
161161

162-
export function celldl2cellml(uri: string, source: string, options: CellMLGenerationOptions|undefined=undefined): CellMLOutput {
162+
export async function celldl2cellml(uri: string, source: string, options: CellMLGenerationOptions|undefined=undefined): Promise<CellMLOutput> {
163163
if (pyodide) {
164164
const bgRdf = options?.rdfSource ? source : getBgRdf(source)
165165
const bg2cellml = pyodide.runPython(RUN_BG2CELLML)
166-
return bg2cellml(uri, bgRdf, options)
166+
return await bg2cellml(uri, bgRdf, options?.metadata, options?.debug)
167167
}
168168
return {
169169
issues: ['CellML conversion service has not been initialised']
@@ -177,7 +177,7 @@ export async function testBg2cellml(): Promise<CellMLOutput> {
177177
const response = await fetch(model_uri)
178178
if (response.ok) {
179179
const model_source = await response.text()
180-
const result = bg2cellml(full_uri, model_source, {
180+
const result = await bg2cellml(full_uri, model_source, {
181181
debug: true,
182182
metadata: true
183183
})

0 commit comments

Comments
 (0)