diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57b2ea3b0..b79232ae3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,8 @@ jobs: # Active LTS + other OS - os: macos-latest node_version: 18 - # - os: windows-latest @tensorflow/tfjs-node in window has problem - # node_version: 18 + - os: windows-latest + node_version: 18 fail-fast: false name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}" steps: @@ -39,6 +39,9 @@ jobs: run: | echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + - name: prepare + run: pnpm pre + - name: Install deps run: pnpm install diff --git a/.prettierignore b/.prettierignore index e032bd65a..abde8bbb4 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,4 +2,5 @@ dist/ LICENSE.md pnpm-lock.yaml pnpm-workspace.yaml -assets \ No newline at end of file +assets +.vscode \ No newline at end of file diff --git a/bin/preinstall.sh b/bin/preinstall.sh new file mode 100644 index 000000000..f4d859c46 --- /dev/null +++ b/bin/preinstall.sh @@ -0,0 +1,2 @@ +# @tensorflow/tfjs-node in github actions +pnpm i -g node-gyp \ No newline at end of file diff --git a/bin/preinstall.ts b/bin/preinstall.ts deleted file mode 100644 index faf48ad83..000000000 --- a/bin/preinstall.ts +++ /dev/null @@ -1,7 +0,0 @@ -if (!/pnpm/.test(process.env.npm_execpath || '')) { - console.warn( - `\u001b[33mThis repository requires using pnpm as the package manager ` + - ` for scripts to work properly.\u001b[39m\n`, - ); - process.exit(1); -} diff --git a/package.json b/package.json index a23b64e73..584bfb85c 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "node": ">=16.0.0" }, "scripts": { + "pre": "sh ./bin/preinstall.sh", "preinstall": "npx only-allow pnpm", "clean": "sh ./bin/clean.sh", "build": "sh ./bin/build.sh", diff --git a/packages/ml/client/index.tsx b/packages/ml/client/index.tsx index d48fc1009..be23eaf58 100644 --- a/packages/ml/client/index.tsx +++ b/packages/ml/client/index.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; import { BrowserRouter } from 'react-router-dom'; import * as tf from '@tensorflow/tfjs'; +import { createLotsOfTensors } from './lib'; const App = () => { // Define a model for linear regression. diff --git a/packages/ml/client/lib.ts b/packages/ml/client/lib.ts index a475e0a09..42d541b0d 100644 --- a/packages/ml/client/lib.ts +++ b/packages/ml/client/lib.ts @@ -6,4 +6,6 @@ export function createLotsOfTensors(): void { const b = tf.scalar(i) a.mul(b).print() } -} \ No newline at end of file +} + +export const cleanMemoryCreateLotsOfTensors = tf.tidy(createLotsOfTensors)