Skip to content

Commit 44df334

Browse files
committed
group paths in a constants.js file
1 parent 2c1f4e4 commit 44df334

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

constants.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const { resolve: pathResolve } = require('path')
2+
3+
const TFJS_PATH = '/tmp/tfjs-node'
4+
const TAR_PATH = pathResolve(__dirname, 'tfjs-node.br')
5+
6+
module.exports = { TFJS_PATH, TAR_PATH }

index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
const tar = require('tar')
22
const iltorb = require('iltorb')
33
const fs = require('fs')
4-
const { resolve: pathResolve } = require('path')
5-
6-
const TFJS_PATH = '/tmp/tfjs-node'
7-
const TAR_PATH = pathResolve(__dirname, 'tfjs-node.br')
4+
const { TFJS_PATH, TAR_PATH } = require('./constants')
85

96
// this hack is required to avoid webpack/rollup/... bundling the required path
107
const requireFunc =

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tfjs-lambda",
3-
"version": "0.0.12",
3+
"version": "0.0.13",
44
"main": "index.js",
55
"license": "MIT",
66
"files": [

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ During cold start, the files are deflated in `/tmp` and required in your node pr
1818

1919
## Motivation
2020

21-
`@tensorflow/tfjs` works with AWS Lambda but the main problem is that it is slow very slow when used in node. On the other hand, `@tensorflow/tfjs-node` is fast when used with node but it is >140mo and it does not fit under AWS Lambda's size limit (50mo).
21+
`@tensorflow/tfjs` works with AWS Lambda but the main problem is that it is slow very slow when used in node. On the other hand, `@tensorflow/tfjs-node` is fast when used with node but it is >140mo and it does not fit under AWS Lambda's size limit (50mo) and it needs to be pre-compiled for lambda for it to work in a lambda environment.
2222

2323
I was looking for an easy way to use tensorflowjs with lambda and I couldn't find any, so I made this package.

scripts/compress.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
const tar = require('tar')
22
const iltorb = require('iltorb')
33
const fs = require('fs')
4+
const { TFJS_PATH, TAR_PATH } = require('../constants')
45

56
tar
6-
.c({ cwd: '/tmp/tfjs-node' }, ['index.js', 'node_modules'])
7+
.c({ cwd: TFJS_PATH }, ['index.js', 'node_modules'])
78
.pipe(iltorb.compressStream())
8-
.pipe(fs.createWriteStream('../tfjs-node.br'))
9+
.pipe(fs.createWriteStream(TAR_PATH))

0 commit comments

Comments
 (0)