Skip to content

Commit a08db01

Browse files
committed
Rename package to @celldl/editor-python-tools and update README to note requirement for @celldl/editor-rdf
1 parent fd48383 commit a08db01

5 files changed

Lines changed: 39 additions & 27 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish the CellDL Editor Tools as a npm package
1+
name: Publish the CellDL Editor Python Tools as a npm package
22
on:
33
workflow_dispatch:
44

@@ -35,11 +35,11 @@ jobs:
3535
- name: Install bun
3636
run: npm install -g bun
3737

38-
- name: Build the CellDL Editor Tools
38+
- name: Build the CellDL Editor Python Tools
3939
run: |
4040
bun install
4141
bun run build
4242
43-
- name: Publish the CellDL Editor on npm
43+
- name: Publish the CellDL Editor Python Tools on npm
4444
run: |
4545
npm publish --access public --no-git-checks

README.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
# CellML generation for the CellDL Editor
1+
# Python tooling for the CellDL Editor
22

3-
This package provides a Javascript function to convert [BG-RDF](https://bg-rdf.org/) bond-graph models, created by the CellDL Editor, into [CellML](https://cellml.org). It does so by bundling the [bg2cellml](https://github.com/CellDL/BG-Tools) Python package with [Pyodide](https://pyodide.org), allowing it to be used in a Javascript envirinment.
3+
This package allows [CellML](https://cellml.org) to be generated for [BG-RDF](https://bg-rdf.org/) bond-graph models created by the CellDL Editor. It does so by bundling the [bg2cellml](https://github.com/CellDL/BG-Tools) Python package with the [Pyodide](https://pyodide.org) distribution, allowing `bg2cellml` to be used in a Javascript envirinment.
44

5-
It is intended to be used in conjunction with the [@celldl/editor](https://www.npmjs.com/package/@celldl/editor) Vue 3 component.
5+
It is intended to be used with the [@celldl/editor](https://www.npmjs.com/package/@celldl/editor) Vue 3 component and the [@celldl/editor-rdf](https://www.npmjs.com/package/@celldl/editor-rdf) BG-RDF framework.
66

77

88
## Installation
99

1010
```
11-
bun add @celldl/editor-tools
11+
bun add @celldl/editor-python-tools
1212
```
1313

1414
## Usage
1515

1616
- **vite.config.ts:**
1717

18-
The use of these tools in a Vite production environment requires a plugin to allow Pyodide to be loaded:
18+
The use of these tools in a Vite production environment requires a plugin for Pyodide:
1919

2020
```typescript
2121
import * as vite from 'vite'
2222

23-
import { pyodidePlugin } from '@celldl/editor-tools/vite'
23+
import { pyodidePlugin } from '@celldl/editor-python-tools/vite'
2424

2525
export default vite.defineConfig({
2626
plugins: [
@@ -31,33 +31,45 @@ export default vite.defineConfig({
3131

3232
- **Application.vue**
3333

34+
Besides a loaded Pyodide environment, the package requres an initialised BG-RDF framework.
35+
3436
```vue
3537
<script setup lang="ts">
3638
import * as vue from 'vue'
3739
38-
// Editor interface
40+
// BG-RDF environment
41+
42+
import * as $rdf from '@celldl/editor-rdf'
43+
44+
// Python tools
45+
46+
import { initialisePython, type PyodideAPI } from '@celldl/editor-python-tools'
47+
import { loadInBrowser } from '@celldl/editor-python-tools/web'
3948
40-
import CellDLEditor from '@celldl/editor'
41-
import { rdfInterface } from '@celldl/editor'
49+
// Initialisation before importing the CellDLEditor Vue component
4250
43-
// Initialisation
51+
const CellDLEditor = vue.defineAsyncComponent(async () => {
4452
45-
import { initialisePython } from '@celldl/editor-tools'
46-
import { loadInBrowser } from '@celldl/editor-tools/web'
47-
import type { PyodideAPI } from '@celldl/editor-tools'
53+
await $rdf.initialise()
54+
55+
const rdfInterface: $rdf.RdfInterface = {
56+
getRdfStatements: $rdf.bgRdfStatements,
57+
oximockRdfModule: $rdf.oxiRdfModule
58+
}
4859
49-
vue.nextTick().then(async () => {
5060
await loadInBrowser().then(async (pyodideApi: PyodideAPI) => {
5161
await initialisePython(pyodideApi, rdfInterface, (msg: string) => {
5262
console.log(msg)
5363
})
5464
})
65+
66+
return import('@celldl/editor')
5567
})
5668
69+
5770
// CellML generation
5871
59-
import { celldl2cellml } from '@celldl/editor-tools'
60-
export type { CellMLOutput } from '@celldl/editor-tools'
72+
import { celldl2cellml, type CellMLOutput } from '@celldl/editor-python-tools'
6173
6274
const celldl: string = '<svg><!-- Valid CellDL --></svg>'
6375
const celldlUri: string = `https://celldl.org/cellml/${name}` // Some URI to identify the source

bun.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"name": "@celldl/editor-tools",
3-
"version": "0.20260217.1",
2+
"name": "@celldl/editor-python-tools",
3+
"version": "0.20260224.0",
44
"author": {
55
"name": "David Brooks",
66
"email": "d.brooks@auckland.ac.nz"
77
},
88
"bugs": {
9-
"url": "https://github.com/CellDL/CellDLEditorTools/issues"
9+
"url": "https://github.com/CellDL/CellDLEditorPythonTools/issues"
1010
},
1111
"description": "Python tools for the CellDL Editor",
1212
"files": [
@@ -23,10 +23,10 @@
2323
"license": "Apache-2.0",
2424
"main": "dist/index.js",
2525
"module": "dist/index.js",
26-
"productName": "CellDLEditorTools",
26+
"productName": "CellDLEditorPythonTools",
2727
"repository": {
2828
"type": "git",
29-
"url": "git+https://github.com/CellDL/CellDLEditorTools.git"
29+
"url": "git+https://github.com/CellDL/CellDLEditorPythonTools.git"
3030
},
3131
"type": "module",
3232
"scripts": {

src/pyodide/vite.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ export interface PyodidePluginOptions {
7676
}
7777

7878
/**
79-
* Vite plugin for `@celldl/editor-tools `, emit missing assets
79+
* Vite plugin for `@celldl/editor-python-tools`, emit missing assets
8080
*/
8181
export function pyodidePlugin(options: PyodidePluginOptions = {}): Plugin[] {
8282
const {
8383
customURL = (key:AssetsKey, _, finalMap: FinalAssetsMap) => path.basename(finalMap.get(key)![0]),
8484
transformAsmJs,
8585
} = options
86-
const distRoot = path.dirname(createRequire(import.meta.url).resolve('@celldl/editor-tools'))
86+
const distRoot = path.dirname(createRequire(import.meta.url).resolve('@celldl/editor-python-tools'))
8787
const assetsNameMap = new Map<AssetsKey, string>()
8888
const finalAssetsPathMap = new Map<AssetsKey, [path: string, source: string | Uint8Array]>()
8989
const importers: [path: string, code: string][] = []

0 commit comments

Comments
 (0)