-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Angus Hollands <[email protected]> Co-authored-by: Rowan Cockett <[email protected]>
- Loading branch information
1 parent
4d4116c
commit 01322e4
Showing
20 changed files
with
917 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'myst-execute': patch | ||
--- | ||
|
||
Add myst-execute package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'myst-common': minor | ||
'myst-cli': minor | ||
--- | ||
|
||
Move IExpressionResult types to myst-common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
jupyter-server | ||
ipykernel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['curvenote'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./tests/execute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# MyST Execute | ||
|
||
Kernel execution of code and inline expressions using Jupyter. | ||
|
||
This package provides a transform that takes a MyST tree, computes the executable content, and stores the results in the AST. It provides basic support for caching of outputs to avoid needless computation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "myst-execute", | ||
"version": "0.0.0", | ||
"sideEffects": false, | ||
"license": "MIT", | ||
"description": "Execute MyST content with Jupyter", | ||
"author": "Franklin Koch <[email protected]>", | ||
"homepage": "https://github.com/executablebooks/mystmd/tree/main/packages/myst-execution", | ||
"type": "module", | ||
"exports": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/executablebooks/mystmd.git" | ||
}, | ||
"scripts": { | ||
"clean": "rimraf dist", | ||
"lint": "eslint \"src/**/!(*.spec).ts\" -c ./.eslintrc.cjs", | ||
"lint:format": "npx prettier --check \"src/**/*.ts\"", | ||
"test": "vitest run", | ||
"test:watch": "vitest watch", | ||
"build:esm": "tsc", | ||
"build": "npm-run-all -l clean -p build:esm" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/executablebooks/mystmd/issues" | ||
}, | ||
"dependencies": { | ||
"myst-common": "^1.1.21", | ||
"vfile": "^5.3.7", | ||
"@jupyterlab/services": "^7.0.0", | ||
"unist-util-select": "^4.0.3", | ||
"which": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"js-yaml": "^4.1.0", | ||
"node-fetch": "^3.3.0", | ||
"@jupyterlab/nbformat": "^3.5.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; | ||
import path from 'node:path'; | ||
|
||
export interface ICache<T> { | ||
test(key: string): boolean; | ||
|
||
get(key: string): T | undefined; | ||
|
||
set(key: string, value: T): void; | ||
} | ||
|
||
/** | ||
* An implementation of a basic cache | ||
*/ | ||
export class LocalDiskCache<T> implements ICache<T> { | ||
constructor(cachePath: string) { | ||
this._cachePath = cachePath; | ||
|
||
if (!existsSync(cachePath)) { | ||
mkdirSync(cachePath, { recursive: true }); | ||
} | ||
} | ||
|
||
private readonly _cachePath: string; | ||
|
||
private _makeKeyPath(key: string): string { | ||
return path.join(this._cachePath, `${key}.json`); | ||
} | ||
|
||
test(key: string): boolean { | ||
return existsSync(this._makeKeyPath(key)); | ||
} | ||
|
||
get(key: string): T | undefined { | ||
const keyPath = this._makeKeyPath(key); | ||
if (!existsSync(keyPath)) { | ||
return undefined; | ||
} | ||
return JSON.parse(readFileSync(keyPath, { encoding: 'utf8' })); | ||
} | ||
|
||
set(key: string, item: T) { | ||
const keyPath = this._makeKeyPath(key); | ||
return writeFileSync(keyPath, JSON.stringify(item), { encoding: 'utf8' }); | ||
} | ||
} |
Oops, something went wrong.