Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate scaffolding for default model #1173

Merged
merged 29 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
aa324c4
Deprecate scaffolding for default model
thekevinscott Oct 4, 2023
6c586c2
Fix type issue
thekevinscott Oct 4, 2023
b983272
Refactor package json to wireit
thekevinscott Oct 4, 2023
8486c65
Add dependencies for wireit
thekevinscott Oct 4, 2023
7447623
Fix deep source issue and remove lint fix commands
thekevinscott Oct 4, 2023
6a92ae7
Fix post install script
thekevinscott Oct 4, 2023
45ae856
Avoid linting from package json in dist
thekevinscott Oct 4, 2023
1a97108
Run lint in parallel
thekevinscott Oct 4, 2023
94bc89f
Fix constants generation
thekevinscott Oct 4, 2023
17eb4c7
Fix issue with wireit colliding with fs.writeFileSync
thekevinscott Oct 4, 2023
1c0a5db
Set up tmate
thekevinscott Oct 4, 2023
f772db3
Move tmate above pnpm
thekevinscott Oct 4, 2023
3c96b0a
Clean up core package json
thekevinscott Oct 4, 2023
cd46fcf
Build core before building default model
thekevinscott Oct 4, 2023
fe2028f
Merge branch 'ks/deprecate-model-scaffolding' of github.com:thekevins…
thekevinscott Oct 4, 2023
74f6160
Do not specify scripts as dependencies
thekevinscott Oct 4, 2023
781d6ec
Move more wireit scripts out of deps
thekevinscott Oct 5, 2023
37aa37f
Move more wireit scripts out of deps in umd
thekevinscott Oct 5, 2023
e54ff61
Fix bundling path
thekevinscott Oct 5, 2023
4bcc483
Clean up wireit dependencies
thekevinscott Oct 5, 2023
eec4889
Merge branch 'main' into ks/deprecate-model-scaffolding
thekevinscott Oct 5, 2023
eca9eff
Fix UMD path again
thekevinscott Oct 5, 2023
9dbc775
Fix bad command
thekevinscott Oct 5, 2023
22d0ae4
Remove bad types
thekevinscott Oct 5, 2023
0c6cd2a
Try specifying entry points for default model
thekevinscott Oct 5, 2023
1c74d5f
Bring back explicit commands
thekevinscott Oct 5, 2023
c839694
Fix entry points
thekevinscott Oct 5, 2023
dedb9d8
Change entry point in package json
thekevinscott Oct 5, 2023
8b72a44
Get rid of js generated files
thekevinscott Oct 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ exclude_patterns = [
"examples/**",
"scripts/**",
"test/**",
"packages/test-scaffolding/**",
"dev/**",
]

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ jobs:
- name: 'Checkout repository'
uses: actions/checkout@v2

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
with:
detached: true

- name: 'Setup PNPM with Node 16'
uses: ./.github/actions/setup-pnpm
with:
Expand Down Expand Up @@ -169,11 +174,6 @@ jobs:
with:
gdrive_credentials_data: ${{ secrets.GDRIVE_CREDENTIALS_DATA }}

# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# with:
# detached: true

- name: 'Build Models'
run: pnpm test:integration:browser -- --ci --verbose --skipTest --skipUpscalerBuild --skipBundle

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ const buildModel = async (
if (opts.verbose) {
console.log(`Scaffolding dependencies for model ${model}`);
}
scaffoldDependencies(MODEL_ROOT, scaffoldDependenciesConfig);
if (model !== 'default-model') {
scaffoldDependencies(MODEL_ROOT, scaffoldDependenciesConfig);
}

// rimraf(DIST);
// await mkDistFolder(DIST);
Expand Down
136 changes: 123 additions & 13 deletions models/default-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@
},
"exports": {
".": {
"require": "./dist/cjs/models/default-model/src/index.js",
"import": "./dist/esm/models/default-model/src/index.js"
"require": "./dist/cjs/models/default-model/src/cjs.js",
"import": "./dist/esm/models/default-model/src/esm.js"
}
},
"module": "dist/esm/models/default-model/src/esm.js",
"types": "dist/esm/models/default-model/src/esm.d.ts",
"umd:main": "dist/umd/models/default-model/src/umd.js",
"scripts": {
"scaffold:dependencies": "ts-node ../../scripts/package-scripts/scaffold-dependencies.ts --src models/default-model --config models/scaffolder.ts",
"lint:fix": "pnpm lint --fix",
"lint": "pnpm scaffold:dependencies && eslint -c ../.eslintrc.js src --ext .ts",
"prepublishOnly": "pnpm lint && pnpm build && pnpm validate:build",
"validate:build": "ts-node ../../scripts/package-scripts/validate-build.ts models/default-model",
"build": "ts-node ../../scripts/package-scripts/build-model.ts default-model -o cjs -o esm -o umd --skipCheckModelsExist",
"build:cjs": "ts-node ../../scripts/package-scripts/build-model.ts default-model -o cjs",
"build:esm": "ts-node ../../scripts/package-scripts/build-model.ts default-model -o esm",
"build:umd": "ts-node ../../scripts/package-scripts/build-model.ts default-model -o umd",
"clean": "ts-node ../../scripts/package-scripts/clean-model.ts default-model"
"lint": "wireit",
"prepublishOnly": "wireit",
"validate:build": "wireit",
"build": "wireit",
"build:cjs": "wireit",
"build:esm": "wireit",
"build:umd": "wireit",
"build:umd:tsc": "wireit",
"build:umd:rollup": "wireit",
"build:umd:uglify": "wireit"
},
"files": [
"assets/**/*",
Expand All @@ -45,15 +48,122 @@
"@tensorflow/tfjs": "~4.8.0"
},
"devDependencies": {
"@rollup/plugin-json": "^6.0.0",
"@tensorflow/tfjs": "~4.8.0",
"@tensorflow/tfjs-core": "~4.8.0",
"@tensorflow/tfjs-layers": "~4.8.0",
"@tensorflow/tfjs": "~4.8.0",
"@tensorflow/tfjs-node": "~4.8.0",
"@tensorflow/tfjs-node-gpu": "~4.8.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"seedrandom": "3.0.5"
},
"@upscalerjs": {
"title": "Default Model",
"modelFamily": "esrgan"
},
"wireit": {
"lint": {
"command": "eslint -c ../.eslintrc.js src --ext .ts"
},
"prepublishOnly": {
"command": "pnpm lint && pnpm build && pnpm validate:build"
},
"validate:build": {
"command": "ts-node ../../scripts/package-scripts/validate-build.ts models/default-model"
},
"scaffold": {
"command": "node -e 'const fs = require(\"fs\"); const {name, version} = require(\"./package.json\"); fs.writeFileSync(\"./src/constants.generated.ts\", `export const NAME = \"${name}\";\\nexport const VERSION=\"${version}\"`, \"utf-8\");'",
"files": [
"package.json"
],
"output": [
"./src/constants.generated.ts"
]
},
"build": {
"command": "pnpm build:cjs && pnpm build:esm && pnpm build:umd",
"dependencies": [
"../../packages/core:build",
"scaffold"
],
"files": [
"src/**/*.ts",
"!src/**/*.test.ts",
"!src/**/*.generated.ts",
"../../../packages/shared/src/esrgan/**/*.ts",
"package.json",
"tsconfig.cjs.json",
"tsconfig.esm.json",
"tsconfig.umd.json",
"tsconfig.json",
"../tsconfig.cjs.json",
"../tsconfig.esm.json",
"../tsconfig.umd.json",
"../tsconfig.json"
],
"output": [
"dist/**"
]
},
"build:cjs": {
"command": "tsc -p ./tsconfig.cjs.json --outDir ./dist/cjs --baseUrl ./src",
"files": [
"src/**/*.ts",
"!src/**/*.test.ts",
"!src/**/*.generated.ts",
"../../../packages/shared/src/esrgan/**/*.ts",
"package.json",
"tsconfig.cjs.json",
"tsconfig.json",
"../tsconfig.cjs.json",
"../tsconfig.json"
],
"output": [
"dist/esm/**"
]
},
"build:esm": {
"command": "tsc -p ./tsconfig.esm.json --outDir ./dist/esm --baseUrl ./src",
"files": [
"src/**/*.ts",
"!src/**/*.test.ts",
"!src/**/*.generated.ts",
"../../../packages/shared/src/esrgan/**/*.ts",
"package.json",
"tsconfig.esm.json",
"tsconfig.json",
"../tsconfig.esm.json",
"../tsconfig.json"
],
"output": [
"dist/esm/**"
]
},
"build:umd": {
"command": "pnpm run build:umd:tsc && pnpm run build:umd:rollup && pnpm run build:umd:uglify && rimraf ./dist/umd-tmp",
"files": [
"src/**/*.ts",
"!src/**/*.test.ts",
"!src/**/*.generated.ts",
"../../../packages/shared/src/esrgan/**/*.ts",
"package.json",
"tsconfig.umd.json",
"tsconfig.json",
"../tsconfig.umd.json",
"../tsconfig.json"
],
"output": [
"dist/umd/**"
]
},
"build:umd:tsc": {
"command": "tsc -p ./tsconfig.umd.json --outDir ./dist/umd-tmp"
},
"build:umd:rollup": {
"command": "rollup -c ../rollup.config.cjs --input ./dist/umd-tmp/models/default-model/src/index.js --file ./dist/umd/index.js --name DefaultUpscalerJSModel --format umd"
},
"build:umd:uglify": {
"command": "uglifyjs ./dist/umd/index.js --output ./dist/umd/index.min.js --compress --mangle --source-map"
}
}
}
2 changes: 2 additions & 0 deletions models/default-model/src/cjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { default as DefaultModel, } from './index';
module.exports = DefaultModel; // eslint-disable-line
1 change: 1 addition & 0 deletions models/default-model/src/esm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as default, } from './index';
2 changes: 2 additions & 0 deletions models/default-model/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const SCALE = 2;

const modelDefinition = getESRGANModelDefinition({
scale: SCALE,
// name: getValue(packageJSON, 'name'),
// version: getValue(packageJSON, 'version'),
name: NAME,
version: VERSION,
path: 'models/model.json',
Expand Down
1 change: 1 addition & 0 deletions models/default-model/src/umd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as default, } from '.';
6 changes: 1 addition & 5 deletions models/default-model/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"extends": "../tsconfig.cjs.json",
"compilerOptions": {
"baseUrl": "./src",
"outDir": "./dist/cjs",
},
"include": [
"./src/index.ts",
"./src/cjs.ts",
]
}
6 changes: 1 addition & 5 deletions models/default-model/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"extends": "../tsconfig.esm.json",
"compilerOptions": {
"baseUrl": "./src",
"outDir": "./dist/esm",
},
"include": [
"./src/index.ts",
"./src/esm.ts",
]
}
2 changes: 1 addition & 1 deletion models/default-model/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "../tsconfig.json",
"include": ["src/**/*.ts"],
"include": ["src/**/*.ts", "src/foo.js"],
"exclude": ["node_modules", "**/*.test.ts"],
"compilerOptions": {
"rootDirs": ["./src", "../../../packages/shared/src"],
Expand Down
6 changes: 1 addition & 5 deletions models/default-model/tsconfig.umd.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"extends": "../tsconfig.umd.json",
"compilerOptions": {
"baseUrl": "./src",
"outDir": "./dist/tmp",
},
"include": [
"./src/index.ts",
"./src/umd.ts",
]
}
20 changes: 20 additions & 0 deletions models/rollup.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const commonjs = require('@rollup/plugin-commonjs');
const rollupJSON = require('@rollup/plugin-json');
const { nodeResolve, } = require('@rollup/plugin-node-resolve');

module.exports = {
context: 'window',
external: [
'@tensorflow/tfjs',
],
plugins: [
nodeResolve({
preferBuiltins: true,
resolveOnly: [
/^(?!.*(@tensorflow\/tfjs))/,
],
}),
commonjs(),
rollupJSON(),
],
};
6 changes: 3 additions & 3 deletions models/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"moduleResolution": "Node",
"moduleResolution": "Node16",
"module": "CommonJS",
"target": "ES5",
"module": "ESNext",
}
},
}
2 changes: 2 additions & 0 deletions models/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"strict": true,
"removeComments": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"declaration": true,
"declarationMap": true,
"noUnusedLocals": true,
Expand All @@ -14,4 +15,5 @@
"noFallthroughCasesInSwitch": true,
"rootDirs": ["./src", "../../../packages/shared/src"],
},
"exclude": ["node_modules", "**/*.test.ts"]
}
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@
"command": "pnpm --filter=!\"@upscalerjs/docs\" --filter=!\"@upscalerjs/examples.*\" install"
},
"postinstall": {
"command": "pnpm --filter @upscalerjs/core --filter @upscalerjs/default-model build"
"dependencies": [
"./packages/core:build",
"./models/default-model:build"
]
},
"update:dependency": {
"command": "pnpm --filter @upscalerjs/scripts update:dependency"
Expand All @@ -196,7 +199,7 @@
"command": "pnpm --filter @upscalerjs/scripts example:start"
},
"lint": {
"command": "pnpm --filter upscaler --filter @upscalerjs/* lint"
"command": "pnpm --parallel --filter=!./models/**/dist/** lint"
},
"model:build": {
"command": "pnpm --filter @upscalerjs/scripts model:build"
Expand All @@ -223,7 +226,7 @@
]
},
"test:integration:node": {
"command": "echo 1",
"command": "pnpm --filter @upscalerjs/scripts test:integration:node",
"dependencies": [
"./packages/upscalerjs:build:node-gpu",
"./packages/upscalerjs:build:node"
Expand Down
Loading