From e396301ba44c6dcb059694a4b57b72754e3778b3 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:09:00 -0400 Subject: [PATCH 01/23] Update package.json --- package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 3bcb3133a..bd6b39419 100644 --- a/package.json +++ b/package.json @@ -12,20 +12,20 @@ "dev:server": "cd pyflask && python -m flask run --port 4242", "build": "npm run build:app", "build:app": "electron-vite build --outDir build", - "build:win": "npm run build && npm run build:flask:win && npm run build:electron:win", - "build:mac": "npm run build && npm run build:flask:unix && npm run build:electron:mac", + "build:win": "npm run build && npm run build:flask && npm run build:electron:win", + "build:mac": "npm run build && npm run build:flask && npm run build:electron:mac", "build:linux": "npm run build && npm run build:flask:unix && npm run build:electron:linux", - "build:flask:base": "python -m PyInstaller --log-level DEBUG --name nwb-guide --onedir --clean --noconfirm ./pyflask/app.py --distpath ./build/flask --collect-data jsonschema_specifications --collect-all nwbinspector --collect-all neuroconv --collect-all pynwb --collect-all hdmf --collect-all ci_info --collect-all ndx_dandi_icephys --hidden-import scipy._distributor_init --hidden-import scipy._lib.messagestream --hidden-import scipy._lib._ccallback --hidden-import scipy._lib._testutils --hidden-import email_validator", - "build:flask:win": "npm run build:flask:base -- --add-data ./paths.config.json;. --add-data ./package.json;.", - "build:flask:unix": "npm run build:flask:base -- --add-data ./paths.config.json:. --add-data ./package.json:.", + "build:flask": "python -m PyInstaller nwb-guide.spec", + "build:flask:spec:base": "python -m PyInstaller --name nwb-guide --onedir --clean --noconfirm ./pyflask/app.py --distpath ./build/flask --collect-data jsonschema_specifications --collect-all nwbinspector --collect-all neuroconv --collect-all pynwb --collect-all hdmf --collect-all ci_info --hidden-import scipy._distributor_init --hidden-import scipy._lib.messagestream --hidden-import scipy._lib._ccallback --hidden-import scipy._lib._testutils", + "build:flask:spec:win": "npm run build:flask:spec:base -- --add-data ./paths.config.json;. --add-data ./package.json;.", + "build:flask:spec:unix": "npm run build:flask:spec:base -- --add-data ./paths.config.json:. --add-data ./package.json:. --collect-all ndx_dandi_icephys", "build:electron:win": "electron-builder build --win --publish never", "build:electron:mac": "electron-builder build --mac --publish never", "build:electron:linux": "electron-builder build --linux --publish never", "test": "npm run test:app && npm run test:server", "test:app": "vitest run", "test:server": "pytest pyflask/tests/ -s", - "wait3s": "node -e \"setTimeout(() => process.exit(0),3000)\"", - "test:executable": "concurrently -n EXE,TEST --kill-others --success first \"node tests/testPyinstallerExecutable.js --port 3434 --forever\" \"npm run wait3s && pytest pyflask/tests/ -s --target http://localhost:3434\"", + "test:executable": "concurrently -n EXE,TEST --kill-others \"node tests/testPyinstallerExecutable.js --port 3434 --forever\" \"pytest pyflask/tests/ -s --target http://localhost:3434\"", "test:coverage": "npm run coverage:app && npm run coverage:server", "coverage:app": "vitest run --coverage", "coverage:server": "pytest pyflask/tests/ -s --cov=pyflask --cov-report=xml", @@ -57,7 +57,7 @@ { "ext": "nwb", "name": "NWB File", - "role": "Viewer" + "role": "Editor" } ], "files": [ From d5812fb45fcee2beb9440baa713a712cd4bd5607 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:10:53 -0400 Subject: [PATCH 02/23] fix alterations --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index bd6b39419..2b3d60ea6 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "test": "npm run test:app && npm run test:server", "test:app": "vitest run", "test:server": "pytest pyflask/tests/ -s", + "wait3s": "node -e \"setTimeout(() => process.exit(0),3000)\"", "test:executable": "concurrently -n EXE,TEST --kill-others \"node tests/testPyinstallerExecutable.js --port 3434 --forever\" \"pytest pyflask/tests/ -s --target http://localhost:3434\"", "test:coverage": "npm run coverage:app && npm run coverage:server", "coverage:app": "vitest run --coverage", @@ -57,7 +58,7 @@ { "ext": "nwb", "name": "NWB File", - "role": "Editor" + "role": "Viewer" } ], "files": [ From 9e83ca7cad85855100418d2c5bdcaa2ec29d4205 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:13:42 -0400 Subject: [PATCH 03/23] restore other --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b3d60ea6..d93b2d6d8 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "test:app": "vitest run", "test:server": "pytest pyflask/tests/ -s", "wait3s": "node -e \"setTimeout(() => process.exit(0),3000)\"", - "test:executable": "concurrently -n EXE,TEST --kill-others \"node tests/testPyinstallerExecutable.js --port 3434 --forever\" \"pytest pyflask/tests/ -s --target http://localhost:3434\"", + "test:executable": "concurrently -n EXE,TEST --kill-others --success first \"node tests/testPyinstallerExecutable.js --port 3434 --forever\" \"npm run wait3s && pytest pyflask/tests/ -s --target http://localhost:3434\"", "test:coverage": "npm run coverage:app && npm run coverage:server", "coverage:app": "vitest run --coverage", "coverage:server": "pytest pyflask/tests/ -s --cov=pyflask --cov-report=xml", From cb98081e6567c581f9438eae927c16f57e345e43 Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 13 Sep 2023 14:54:47 -0400 Subject: [PATCH 04/23] add spec file for windows --- .gitignore | 2 -- nwb-guide-windows.spec | 70 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 nwb-guide-windows.spec diff --git a/.gitignore b/.gitignore index 852548470..0cda7e019 100644 --- a/.gitignore +++ b/.gitignore @@ -19,8 +19,6 @@ semantic.json build/ yarn.lock -*.spec - *.pyc src/.DS_Store .DS_Store diff --git a/nwb-guide-windows.spec b/nwb-guide-windows.spec new file mode 100644 index 000000000..09f97562f --- /dev/null +++ b/nwb-guide-windows.spec @@ -0,0 +1,70 @@ +# -*- mode: python ; coding: utf-8 -*- +import sys +sys.setrecursionlimit(sys.getrecursionlimit() * 5) + +from PyInstaller.utils.hooks import collect_data_files +from PyInstaller.utils.hooks import collect_all + +datas = [('./paths.config.json', '.'), ('./package.json', '.')] +binaries = [] +hiddenimports = ['scipy._distributor_init', 'scipy._lib.messagestream', 'scipy._lib._ccallback', 'scipy._lib._testutils'] +datas += collect_data_files('jsonschema_specifications') +tmp_ret = collect_all('nwbinspector') +datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] +tmp_ret = collect_all('neuroconv') +datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] +tmp_ret = collect_all('pynwb') +datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] +tmp_ret = collect_all('hdmf') +datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] +tmp_ret = collect_all('ci_info') +datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] + + +block_cipher = None + + +a = Analysis( + ['pyflask\\app.py'], + pathex=[], + binaries=binaries, + datas=datas, + hiddenimports=hiddenimports, + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False, +) +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) + +exe = EXE( + pyz, + a.scripts, + [], + exclude_binaries=True, + name='nwb-guide', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) +coll = COLLECT( + exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='nwb-guide', +) From 0e1e839b492f704299cd1b0ab7a787b8b47a9a1c Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 13 Sep 2023 14:55:52 -0400 Subject: [PATCH 05/23] new commands --- package.json | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d93b2d6d8..6e2db7464 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,13 @@ "dev:server": "cd pyflask && python -m flask run --port 4242", "build": "npm run build:app", "build:app": "electron-vite build --outDir build", - "build:win": "npm run build && npm run build:flask && npm run build:electron:win", - "build:mac": "npm run build && npm run build:flask && npm run build:electron:mac", + "build:win": "npm run build && npm run build:flask:win && npm run build:electron:win", + "build:mac": "npm run build && npm run build:flask:unix && npm run build:electron:mac", "build:linux": "npm run build && npm run build:flask:unix && npm run build:electron:linux", - "build:flask": "python -m PyInstaller nwb-guide.spec", - "build:flask:spec:base": "python -m PyInstaller --name nwb-guide --onedir --clean --noconfirm ./pyflask/app.py --distpath ./build/flask --collect-data jsonschema_specifications --collect-all nwbinspector --collect-all neuroconv --collect-all pynwb --collect-all hdmf --collect-all ci_info --hidden-import scipy._distributor_init --hidden-import scipy._lib.messagestream --hidden-import scipy._lib._ccallback --hidden-import scipy._lib._testutils", - "build:flask:spec:win": "npm run build:flask:spec:base -- --add-data ./paths.config.json;. --add-data ./package.json;.", + "build:flask:win": "python -m PyInstaller nwb-guide-windows.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", + "build:flask:spec:base": "pyi-makespec --name nwb-guide --onedir --collect-data jsonschema_specifications --collect-all nwbinspector --collect-all neuroconv --collect-all pynwb --collect-all hdmf --collect-all ci_info --hidden-import scipy._distributor_init --hidden-import scipy._lib.messagestream --hidden-import scipy._lib._ccallback --hidden-import scipy._lib._testutils ./pyflask/app.py", + "rename:spec:windows": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-windows.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", + "build:flask:spec:win": "npm run build:flask:spec:base -- --add-data ./paths.config.json;. --add-data ./package.json;. && npm run rename:spec:windows", "build:flask:spec:unix": "npm run build:flask:spec:base -- --add-data ./paths.config.json:. --add-data ./package.json:. --collect-all ndx_dandi_icephys", "build:electron:win": "electron-builder build --win --publish never", "build:electron:mac": "electron-builder build --mac --publish never", From 610de05202970455f985c8130de9f792cee2c9e5 Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 13 Sep 2023 15:03:09 -0400 Subject: [PATCH 06/23] add other renames --- package.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/package.json b/package.json index 6e2db7464..602798335 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,12 @@ "rename:spec:windows": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-windows.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", "build:flask:spec:win": "npm run build:flask:spec:base -- --add-data ./paths.config.json;. --add-data ./package.json;. && npm run rename:spec:windows", "build:flask:spec:unix": "npm run build:flask:spec:base -- --add-data ./paths.config.json:. --add-data ./package.json:. --collect-all ndx_dandi_icephys", + "rename:spec:mac": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-mac.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", + "build:flask:spec:mac": "npm run build:flask:spec:mac && npm run rename:spec:mac", + "rename:spec:mac-arm64": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-mac-arm64.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", + "build:flask:spec:mac-arm64": "npm run build:flask:spec:mac-arm64 && npm run rename:spec:mac-arm64", + "rename:spec:linux": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-linux.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", + "build:flask:spec:linux": "npm run build:flask:spec:unix && npm run rename:spec:linux", "build:electron:win": "electron-builder build --win --publish never", "build:electron:mac": "electron-builder build --mac --publish never", "build:electron:linux": "electron-builder build --linux --publish never", From cf691191a8b7313c7f79b8719b1bb9bcf42ab63d Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 13 Sep 2023 15:04:23 -0400 Subject: [PATCH 07/23] add other build calls --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 602798335..4f6278343 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,9 @@ "build:mac": "npm run build && npm run build:flask:unix && npm run build:electron:mac", "build:linux": "npm run build && npm run build:flask:unix && npm run build:electron:linux", "build:flask:win": "python -m PyInstaller nwb-guide-windows.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", + "build:flask:mac": "python -m PyInstaller nwb-guide-mac.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", + "build:flask:mac-arm64": "python -m PyInstaller nwb-guide-mac-arm64.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", + "build:flask:linux": "python -m PyInstaller nwb-guide-linux.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", "build:flask:spec:base": "pyi-makespec --name nwb-guide --onedir --collect-data jsonschema_specifications --collect-all nwbinspector --collect-all neuroconv --collect-all pynwb --collect-all hdmf --collect-all ci_info --hidden-import scipy._distributor_init --hidden-import scipy._lib.messagestream --hidden-import scipy._lib._ccallback --hidden-import scipy._lib._testutils ./pyflask/app.py", "rename:spec:windows": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-windows.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", "build:flask:spec:win": "npm run build:flask:spec:base -- --add-data ./paths.config.json;. --add-data ./package.json;. && npm run rename:spec:windows", From a807e65c5fe33d08671d0feb9c96574dddf283eb Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 13 Sep 2023 15:05:14 -0400 Subject: [PATCH 08/23] propagate to top level --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4f6278343..d475f4018 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,9 @@ "build": "npm run build:app", "build:app": "electron-vite build --outDir build", "build:win": "npm run build && npm run build:flask:win && npm run build:electron:win", - "build:mac": "npm run build && npm run build:flask:unix && npm run build:electron:mac", - "build:linux": "npm run build && npm run build:flask:unix && npm run build:electron:linux", + "build:mac": "npm run build && npm run build:flask:mac && npm run build:electron:mac", + "build:mac-arm64": "npm run build && npm run build:flask:mac-arm64 && npm run build:electron:mac", + "build:linux": "npm run build && npm run build:flask:linux && npm run build:electron:linux", "build:flask:win": "python -m PyInstaller nwb-guide-windows.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", "build:flask:mac": "python -m PyInstaller nwb-guide-mac.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", "build:flask:mac-arm64": "python -m PyInstaller nwb-guide-mac-arm64.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", From 69efd18daac7cddf7dbcc6371329d350be4c3471 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 13 Sep 2023 15:28:30 -0400 Subject: [PATCH 09/23] forgot hidden import --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d475f4018..f8efae261 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "build:flask:mac": "python -m PyInstaller nwb-guide-mac.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", "build:flask:mac-arm64": "python -m PyInstaller nwb-guide-mac-arm64.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", "build:flask:linux": "python -m PyInstaller nwb-guide-linux.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", - "build:flask:spec:base": "pyi-makespec --name nwb-guide --onedir --collect-data jsonschema_specifications --collect-all nwbinspector --collect-all neuroconv --collect-all pynwb --collect-all hdmf --collect-all ci_info --hidden-import scipy._distributor_init --hidden-import scipy._lib.messagestream --hidden-import scipy._lib._ccallback --hidden-import scipy._lib._testutils ./pyflask/app.py", + "build:flask:spec:base": "pyi-makespec --name nwb-guide --onedir --collect-data jsonschema_specifications --collect-all nwbinspector --collect-all neuroconv --collect-all pynwb --collect-all hdmf --collect-all ci_info --hidden-import scipy._distributor_init --hidden-import scipy._lib.messagestream --hidden-import scipy._lib._ccallback --hidden-import scipy._lib._testutils --hidden-import email_validator ./pyflask/app.py", "rename:spec:windows": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-windows.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", "build:flask:spec:win": "npm run build:flask:spec:base -- --add-data ./paths.config.json;. --add-data ./package.json;. && npm run rename:spec:windows", "build:flask:spec:unix": "npm run build:flask:spec:base -- --add-data ./paths.config.json:. --add-data ./package.json:. --collect-all ndx_dandi_icephys", From 1f97066df8744344e58572664ed373e723c2d595 Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 13 Sep 2023 15:55:06 -0400 Subject: [PATCH 10/23] update spec file, duh --- nwb-guide-windows.spec | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nwb-guide-windows.spec b/nwb-guide-windows.spec index 09f97562f..1b46759fa 100644 --- a/nwb-guide-windows.spec +++ b/nwb-guide-windows.spec @@ -1,13 +1,10 @@ # -*- mode: python ; coding: utf-8 -*- -import sys -sys.setrecursionlimit(sys.getrecursionlimit() * 5) - from PyInstaller.utils.hooks import collect_data_files from PyInstaller.utils.hooks import collect_all datas = [('./paths.config.json', '.'), ('./package.json', '.')] binaries = [] -hiddenimports = ['scipy._distributor_init', 'scipy._lib.messagestream', 'scipy._lib._ccallback', 'scipy._lib._testutils'] +hiddenimports = ['scipy._distributor_init', 'scipy._lib.messagestream', 'scipy._lib._ccallback', 'scipy._lib._testutils', 'email_validator'] datas += collect_data_files('jsonschema_specifications') tmp_ret = collect_all('nwbinspector') datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] From b3a68d68b52b81da266ce05adf68f38e5e53da53 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:43:55 -0400 Subject: [PATCH 11/23] re-add recursion limit hack, duh --- nwb-guide-windows.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nwb-guide-windows.spec b/nwb-guide-windows.spec index 1b46759fa..e3a9a731d 100644 --- a/nwb-guide-windows.spec +++ b/nwb-guide-windows.spec @@ -1,4 +1,7 @@ # -*- mode: python ; coding: utf-8 -*- +import sys +sys.setrecursionlimit(sys.getrecursionlimit() * 5) + from PyInstaller.utils.hooks import collect_data_files from PyInstaller.utils.hooks import collect_all From 6e1e1ef3b5f63c0fc13d4f241140f9948eb4176f Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 13 Sep 2023 22:08:27 -0400 Subject: [PATCH 12/23] re-add ndx-icephys --- nwb-guide-windows.spec | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nwb-guide-windows.spec b/nwb-guide-windows.spec index e3a9a731d..93640b066 100644 --- a/nwb-guide-windows.spec +++ b/nwb-guide-windows.spec @@ -17,6 +17,8 @@ tmp_ret = collect_all('pynwb') datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] tmp_ret = collect_all('hdmf') datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] +tmp_ret = collect_all('ndx_dandi_icephys') +datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] tmp_ret = collect_all('ci_info') datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] diff --git a/package.json b/package.json index f8efae261..c6f5b1487 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "build:flask:mac": "python -m PyInstaller nwb-guide-mac.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", "build:flask:mac-arm64": "python -m PyInstaller nwb-guide-mac-arm64.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", "build:flask:linux": "python -m PyInstaller nwb-guide-linux.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", - "build:flask:spec:base": "pyi-makespec --name nwb-guide --onedir --collect-data jsonschema_specifications --collect-all nwbinspector --collect-all neuroconv --collect-all pynwb --collect-all hdmf --collect-all ci_info --hidden-import scipy._distributor_init --hidden-import scipy._lib.messagestream --hidden-import scipy._lib._ccallback --hidden-import scipy._lib._testutils --hidden-import email_validator ./pyflask/app.py", + "build:flask:spec:base": "pyi-makespec --name nwb-guide --onedir --collect-data jsonschema_specifications --collect-all nwbinspector --collect-all neuroconv --collect-all pynwb --collect-all hdmf --collect-all ndx_dandi_icephys --collect-all ci_info --hidden-import scipy._distributor_init --hidden-import scipy._lib.messagestream --hidden-import scipy._lib._ccallback --hidden-import scipy._lib._testutils --hidden-import email_validator ./pyflask/app.py", "rename:spec:windows": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-windows.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", "build:flask:spec:win": "npm run build:flask:spec:base -- --add-data ./paths.config.json;. --add-data ./package.json;. && npm run rename:spec:windows", "build:flask:spec:unix": "npm run build:flask:spec:base -- --add-data ./paths.config.json:. --add-data ./package.json:. --collect-all ndx_dandi_icephys", From 7c1c3c0a7becd8b6ff5591c421df7d11c298db0e Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 13 Sep 2023 23:46:00 -0400 Subject: [PATCH 13/23] simpify cross-platform; update workflows --- .github/workflows/Build-and-deploy-mac.yml | 1 - .../pyflask-build-and-dist-tests.yml | 17 ++--------- nwb-guide-windows.spec => nwb-guide.spec | 0 package.json | 23 ++++---------- prepare_pyinstaller_spec.py | 30 +++++++++++++++++++ 5 files changed, 39 insertions(+), 32 deletions(-) rename nwb-guide-windows.spec => nwb-guide.spec (100%) create mode 100644 prepare_pyinstaller_spec.py diff --git a/.github/workflows/Build-and-deploy-mac.yml b/.github/workflows/Build-and-deploy-mac.yml index dd7a77988..7e8afcfe5 100644 --- a/.github/workflows/Build-and-deploy-mac.yml +++ b/.github/workflows/Build-and-deploy-mac.yml @@ -22,7 +22,6 @@ jobs: - uses: conda-incubator/setup-miniconda@v2 with: activate-environment: nwb-guide - #mamba-version: "*" environment-file: environments/environment-MAC.yml auto-activate-base: false diff --git a/.github/workflows/pyflask-build-and-dist-tests.yml b/.github/workflows/pyflask-build-and-dist-tests.yml index 5fbea858d..b2b89d50b 100644 --- a/.github/workflows/pyflask-build-and-dist-tests.yml +++ b/.github/workflows/pyflask-build-and-dist-tests.yml @@ -30,19 +30,16 @@ jobs: os: ubuntu-latest label: environments/environment-Linux.yml prefix: /usr/share/miniconda3/envs/nwb-guide - shorthand: unix - - python-version: "3.10" + - python-version: "3.9" os: macos-latest label: environments/environment-Mac.yml prefix: /Users/runner/miniconda3/envs/nwb-guide - shorthand: unix - - python-version: "3.10" + - python-version: "3.9" os: windows-latest label: environments/environment-Windows.yml prefix: C:\Miniconda3\envs\nwb-guide - shorthand: win steps: - uses: actions/checkout@v3 @@ -88,15 +85,7 @@ jobs: run: rm -f /Users/runner/miniconda3/envs/nwb-guide/lib/python3.9/site-packages/sonpy/linux/sonpy.so - name: Build PyFlask distribution - run: npm run build:flask:${{ matrix.shorthand }} - - #- if: matrix.os == 'windows-latest' - # name: Run test on build executable - # run: node tests/testPyinstallerExecutable.js --script ./build/nwb-guide/nwb-guide.exe - - #- if: matrix.os != 'windows-latest' - # name: Run test on build executable - # run: node tests/testPyinstallerExecutable.js --script ./build/nwb-guide/nwb-guide + run: npm run build:flask - name: Run test on distributed executable run: node tests/testPyinstallerExecutable.js diff --git a/nwb-guide-windows.spec b/nwb-guide.spec similarity index 100% rename from nwb-guide-windows.spec rename to nwb-guide.spec diff --git a/package.json b/package.json index c6f5b1487..28727a469 100644 --- a/package.json +++ b/package.json @@ -11,25 +11,14 @@ "dev:app": "vite src/renderer", "dev:server": "cd pyflask && python -m flask run --port 4242", "build": "npm run build:app", + "echo": "python -c \"print('hello')\"", "build:app": "electron-vite build --outDir build", - "build:win": "npm run build && npm run build:flask:win && npm run build:electron:win", - "build:mac": "npm run build && npm run build:flask:mac && npm run build:electron:mac", - "build:mac-arm64": "npm run build && npm run build:flask:mac-arm64 && npm run build:electron:mac", - "build:linux": "npm run build && npm run build:flask:linux && npm run build:electron:linux", - "build:flask:win": "python -m PyInstaller nwb-guide-windows.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", - "build:flask:mac": "python -m PyInstaller nwb-guide-mac.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", - "build:flask:mac-arm64": "python -m PyInstaller nwb-guide-mac-arm64.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", - "build:flask:linux": "python -m PyInstaller nwb-guide-linux.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", + "build:win": "npm run build && npm run build:flask && npm run build:electron:win", + "build:mac": "npm run build && npm run build:flask && npm run build:electron:mac", + "build:linux": "npm run build && npm run build:flask && npm run build:electron:linux", + "build:flask": "python -m PyInstaller nwb-guide.spec --log-level DEBUG --clean --noconfirm --distpath ./build/flask", "build:flask:spec:base": "pyi-makespec --name nwb-guide --onedir --collect-data jsonschema_specifications --collect-all nwbinspector --collect-all neuroconv --collect-all pynwb --collect-all hdmf --collect-all ndx_dandi_icephys --collect-all ci_info --hidden-import scipy._distributor_init --hidden-import scipy._lib.messagestream --hidden-import scipy._lib._ccallback --hidden-import scipy._lib._testutils --hidden-import email_validator ./pyflask/app.py", - "rename:spec:windows": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-windows.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", - "build:flask:spec:win": "npm run build:flask:spec:base -- --add-data ./paths.config.json;. --add-data ./package.json;. && npm run rename:spec:windows", - "build:flask:spec:unix": "npm run build:flask:spec:base -- --add-data ./paths.config.json:. --add-data ./package.json:. --collect-all ndx_dandi_icephys", - "rename:spec:mac": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-mac.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", - "build:flask:spec:mac": "npm run build:flask:spec:mac && npm run rename:spec:mac", - "rename:spec:mac-arm64": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-mac-arm64.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", - "build:flask:spec:mac-arm64": "npm run build:flask:spec:mac-arm64 && npm run rename:spec:mac-arm64", - "rename:spec:linux": "node -e \"require('fs').rename('nwb-guide.spec', 'nwb-guide-linux.spec', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", - "build:flask:spec:linux": "npm run build:flask:spec:unix && npm run rename:spec:linux", + "build:flask:spec": "npm run build:flask:spec:base && python prepare_pyinstaller_spec.py", "build:electron:win": "electron-builder build --win --publish never", "build:electron:mac": "electron-builder build --mac --publish never", "build:electron:linux": "electron-builder build --linux --publish never", diff --git a/prepare_pyinstaller_spec.py b/prepare_pyinstaller_spec.py new file mode 100644 index 000000000..41d2cc6d6 --- /dev/null +++ b/prepare_pyinstaller_spec.py @@ -0,0 +1,30 @@ +""" +Calling `pyi-makespec` regenerates the base spec file, but we need to extend the recursion limit. + +This script is run automatically as a part of `npm run build:flask:spec` after the `pyi-makespec` call. +""" + + +def test(): + from pathlib import Path + + with open(file=Path(__file__).parent / "nwb-guide.spec", mode="r") as io: + lines = io.readlines() + + lines.insert(1, "import sys\n") + lines.insert(2, "sys.setrecursionlimit(sys.getrecursionlimit() * 5)\n") + lines.insert(3, "\n") + + # Originally this was a separate `npm` command per platform to account for CLI syntax differences between ; and : + # The spec file is, however, the same across platforms + data_line_index = lines.index("datas = []\n") + lines[data_line_index] = "datas = [('./paths.config.json', '.'), ('./package.json', '.')]\n" + + with open(file=Path(__file__).parent / "nwb-guide.spec", mode="w") as io: + io.writelines(lines) + + print("Sucessfully injected recursion depth extension and json paths!") + + +if __name__ == "__main__": + test() From a9ddea5f8f250dbff3208fdfaaa59673e3f1e436 Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 13 Sep 2023 23:48:18 -0400 Subject: [PATCH 14/23] simplify python --- prepare_pyinstaller_spec.py | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/prepare_pyinstaller_spec.py b/prepare_pyinstaller_spec.py index 41d2cc6d6..2e69cb49e 100644 --- a/prepare_pyinstaller_spec.py +++ b/prepare_pyinstaller_spec.py @@ -3,28 +3,21 @@ This script is run automatically as a part of `npm run build:flask:spec` after the `pyi-makespec` call. """ +from pathlib import Path +with open(file=Path(__file__).parent / "nwb-guide.spec", mode="r") as io: + lines = io.readlines() -def test(): - from pathlib import Path +lines.insert(1, "import sys\n") +lines.insert(2, "sys.setrecursionlimit(sys.getrecursionlimit() * 5)\n") +lines.insert(3, "\n") - with open(file=Path(__file__).parent / "nwb-guide.spec", mode="r") as io: - lines = io.readlines() +# Originally this was a separate `npm` command per platform to account for CLI syntax differences between ; and : +# The spec file is, however, the same across platforms +data_line_index = lines.index("datas = []\n") +lines[data_line_index] = "datas = [('./paths.config.json', '.'), ('./package.json', '.')]\n" - lines.insert(1, "import sys\n") - lines.insert(2, "sys.setrecursionlimit(sys.getrecursionlimit() * 5)\n") - lines.insert(3, "\n") +with open(file=Path(__file__).parent / "nwb-guide.spec", mode="w") as io: + io.writelines(lines) - # Originally this was a separate `npm` command per platform to account for CLI syntax differences between ; and : - # The spec file is, however, the same across platforms - data_line_index = lines.index("datas = []\n") - lines[data_line_index] = "datas = [('./paths.config.json', '.'), ('./package.json', '.')]\n" - - with open(file=Path(__file__).parent / "nwb-guide.spec", mode="w") as io: - io.writelines(lines) - - print("Sucessfully injected recursion depth extension and json paths!") - - -if __name__ == "__main__": - test() +print("Sucessfully injected recursion depth extension and json paths!") From 1d5579b21220a023404c421840bb35cf0e2d729f Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Thu, 14 Sep 2023 00:22:19 -0400 Subject: [PATCH 15/23] modify spec to be platform indepedent --- nwb-guide.spec | 4 +++- prepare_pyinstaller_spec.py | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/nwb-guide.spec b/nwb-guide.spec index 93640b066..8b4f5649d 100644 --- a/nwb-guide.spec +++ b/nwb-guide.spec @@ -1,5 +1,7 @@ # -*- mode: python ; coding: utf-8 -*- import sys +from pathlib import Path + sys.setrecursionlimit(sys.getrecursionlimit() * 5) from PyInstaller.utils.hooks import collect_data_files @@ -27,7 +29,7 @@ block_cipher = None a = Analysis( - ['pyflask\\app.py'], + [f"{Path('pyflask') / 'app.py'}"], pathex=[], binaries=binaries, datas=datas, diff --git a/prepare_pyinstaller_spec.py b/prepare_pyinstaller_spec.py index 2e69cb49e..db06d8e91 100644 --- a/prepare_pyinstaller_spec.py +++ b/prepare_pyinstaller_spec.py @@ -9,14 +9,21 @@ lines = io.readlines() lines.insert(1, "import sys\n") -lines.insert(2, "sys.setrecursionlimit(sys.getrecursionlimit() * 5)\n") +lines.insert(2, "from pathlib import Path\n") lines.insert(3, "\n") +lines.insert(4, "sys.setrecursionlimit(sys.getrecursionlimit() * 5)\n") +lines.insert(5, "\n") # Originally this was a separate `npm` command per platform to account for CLI syntax differences between ; and : # The spec file is, however, the same across platforms data_line_index = lines.index("datas = []\n") lines[data_line_index] = "datas = [('./paths.config.json', '.'), ('./package.json', '.')]\n" +# Another platform specific difference is the app.py location +app_py_line_index = next(index for index, line in enumerate(lines) if "app.py" in line) +app_py_line = " [f\"{Path('pyflask') / 'app.py'}\"],\n" +lines[app_py_line_index] = app_py_line + with open(file=Path(__file__).parent / "nwb-guide.spec", mode="w") as io: io.writelines(lines) From b99b3391edee2a546593a32f9ed7331dbe18a626 Mon Sep 17 00:00:00 2001 From: Garrett Date: Thu, 14 Sep 2023 10:07:12 -0700 Subject: [PATCH 16/23] DANDI upload updates --- schemas/json/dandi/global.json | 22 ++++++++++++++----- src/renderer/src/stories/JSONSchemaForm.js | 22 ++++++++++++++++--- src/renderer/src/stories/JSONSchemaInput.js | 3 ++- src/renderer/src/stories/forms/utils.ts | 4 +++- src/renderer/src/stories/pages/Page.js | 2 +- .../pages/guided-mode/data/GuidedMetadata.js | 5 +++-- .../guided-mode/data/GuidedSourceData.js | 1 + .../stories/pages/settings/SettingsPage.js | 4 ++-- .../src/stories/pages/uploads/UploadsPage.js | 11 +++++++--- 9 files changed, 55 insertions(+), 19 deletions(-) diff --git a/schemas/json/dandi/global.json b/schemas/json/dandi/global.json index c841a1cf8..1680fd34d 100644 --- a/schemas/json/dandi/global.json +++ b/schemas/json/dandi/global.json @@ -1,10 +1,20 @@ { + "description": "Log in to DANDI, click on your user initials in the top-right corner, and copy your API key from the resulting pop-up.
Note: The main archive and the staging (testing) server have different API keys.", "properties": { - "api_key": { - "type": "string", - "format": "password", - "description": "Log in to DANDI, click on your user initials in the top-right corner, and copy your API key from the resulting pop-up.
Note: The main archive and the staging (testing) server have different API keys." + "api_keys": { + "properties": { + "main_api_key": { + "type": "string", + "format": "password", + "description": "From the main archive" + }, + "staging_api_key": { + "type": "string", + "format": "password", + "description": "From the staging (testing) server" + } + }, + "required": ["main_api_key", "staging_api_key"] } - }, - "required": ["api_key"] + } } diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index aa2912722..bbd554182 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -114,6 +114,22 @@ pre { .required.conditional label:after { color: transparent; } + + h4 { + margin: 0; + margin-bottom: 5px; + padding-bottom: 5px; + border-bottom: 1px solid gainsboro; + } + + .guided--text-input-instructions { + font-size: 13px; + width: 100%; + padding-top: 4px; + color: dimgray !important; + margin: 0 0 1em; + line-height: 1.4285em; +} `; document.addEventListener("dragover", (e) => { @@ -238,10 +254,10 @@ export class JSONSchemaForm extends LitElement { // NOTE: Forms with nested forms will handle their own state updates if (!value) { - delete resultParent[name]; + if (fullPath.length === 1) delete resultParent[name]; delete resolvedParent[name]; } else { - resultParent[name] = value; + if (fullPath.length === 1) resultParent[name] = value; resolvedParent[name] = value; } @@ -836,7 +852,7 @@ export class JSONSchemaForm extends LitElement { return html`
- ${false ? html`

${schema.title}

` : ""} ${false ? html`

${schema.description}

` : ""} + ${schema.description ? html`

Description

${unsafeHTML(schema.description)}

` : ""} ${this.#render(schema, this.resolved, this.#requirements)}
`; diff --git a/src/renderer/src/stories/JSONSchemaInput.js b/src/renderer/src/stories/JSONSchemaInput.js index fde0b43af..0a6a7ea07 100644 --- a/src/renderer/src/stories/JSONSchemaInput.js +++ b/src/renderer/src/stories/JSONSchemaInput.js @@ -1,4 +1,5 @@ import { LitElement, css, html } from "lit"; +import { unsafeHTML } from 'lit/directives/unsafe-html.js' import { FilesystemSelector } from "./FileSystemSelector"; import { BasicTable } from "./BasicTable"; @@ -136,7 +137,7 @@ export class JSONSchemaInput extends LitElement { ${input} ${info.description ? html`

- ${capitalize(info.description)}${info.description.slice(-1)[0] === "." ? "" : "."} + ${unsafeHTML(capitalize(info.description))}${info.description.slice(-1)[0] === "." ? "" : "."}

` : ""} `; diff --git a/src/renderer/src/stories/forms/utils.ts b/src/renderer/src/stories/forms/utils.ts index 8a1973675..30660bc4f 100644 --- a/src/renderer/src/stories/forms/utils.ts +++ b/src/renderer/src/stories/forms/utils.ts @@ -1,4 +1,6 @@ -export const capitalize = (str: string) => str[0].toUpperCase() + str.slice(1) +const toCapitalizeAll = ['nwb', 'api', 'id'] + +export const capitalize = (str: string) => toCapitalizeAll.includes(str.toLowerCase()) ? str.toUpperCase() : str[0].toUpperCase() + str.slice(1) export const header = (headerStr: string) => { diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js index c4a52659b..07d3ef6ea 100644 --- a/src/renderer/src/stories/pages/Page.js +++ b/src/renderer/src/stories/pages/Page.js @@ -17,7 +17,7 @@ export class Page extends LitElement { // ); // } - info = { globalState: {} }; + info = { globalState: {}, states: { saved: false } }; constructor(info = {}) { super(); diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedMetadata.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedMetadata.js index 583ccbee2..ab9ddeb7b 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedMetadata.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedMetadata.js @@ -58,18 +58,19 @@ export class GuidedMetadataPage extends ManagedPage { createForm = ({ subject, session, info }) => { // const results = createResults({ subject, info }, this.info.globalState); - const globalState = this.info.globalState; + const { globalState } = this.info; const results = info.metadata; // Edited form info // Define the appropriate global metadata to fill empty values in the form - const aggregateGlobalMetadata = resolveGlobalOverrides(subject, this.info.globalState); + const aggregateGlobalMetadata = resolveGlobalOverrides(subject, globalState); // Define the correct instance identifier const instanceId = `sub-${subject}/ses-${session}`; // Ignore specific metadata in the form by removing their schema value const schema = globalState.schema.metadata[subject][session]; + delete schema.description; delete schema.properties.NWBFile.properties.source_script; delete schema.properties.NWBFile.properties.source_script_file_name; diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js index 5abb23272..eacd86b3a 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js @@ -104,6 +104,7 @@ export class GuidedSourceDataPage extends ManagedPage { const instanceId = `sub-${subject}/ses-${session}`; const schema = this.info.globalState.schema.source_data; + delete schema.description; const form = new JSONSchemaForm({ identifier: instanceId, diff --git a/src/renderer/src/stories/pages/settings/SettingsPage.js b/src/renderer/src/stories/pages/settings/SettingsPage.js index c0ae474f8..69cef8a23 100644 --- a/src/renderer/src/stories/pages/settings/SettingsPage.js +++ b/src/renderer/src/stories/pages/settings/SettingsPage.js @@ -40,7 +40,7 @@ export class SettingsPage extends Page { const res = resolved[prop]; if (propInfo) setUndefinedIfNotDeclared(propInfo, res); } - if (!("api_key" in resolved.DANDI)) resolved.DANDI.api_key = undefined; + merge(this.form.resolved, global.data); global.save(); // Save the changes, even if invalid on the form @@ -69,7 +69,7 @@ export class SettingsPage extends Page { onUpdate: () => (this.unsavedUpdates = true), validateOnChange: (name, parent) => { const value = parent[name]; - if (name === "api_key") return dandiAPITokenRegex.test(value); + if (name.includes("api_key")) return dandiAPITokenRegex.test(value); return true; }, onThrow, diff --git a/src/renderer/src/stories/pages/uploads/UploadsPage.js b/src/renderer/src/stories/pages/uploads/UploadsPage.js index 2e4691212..2ed2331d1 100644 --- a/src/renderer/src/stories/pages/uploads/UploadsPage.js +++ b/src/renderer/src/stories/pages/uploads/UploadsPage.js @@ -19,10 +19,15 @@ import { DandiResults } from "../../DandiResults.js"; export const isStaging = (id) => parseInt(id) >= 100000; export async function uploadToDandi(info, type = "project" in info ? "" : "folder") { - const api_key = global.data.DANDI?.api_key; + + const staging = isStaging(info.dandiset_id) // Automatically detect staging IDs + + const whichAPIKey = staging ? 'staging_api_key' : 'main_api_key' + const api_key = global.data.DANDI?.api_keys?.[whichAPIKey]; + if (!api_key) { await Swal.fire({ - title: "Your DANDI API key is not configured.", + title: `Your DANDI API key (${whichAPIKey}) is not configured.`, html: "Edit your settings to include this value.", icon: "warning", confirmButtonText: "Go to Settings", @@ -35,7 +40,7 @@ export async function uploadToDandi(info, type = "project" in info ? "" : "folde type ? `upload/${type}` : "upload", { ...info, - staging: isStaging(info.dandiset_id), // Automatically detect staging IDs + staging, api_key, }, { title: "Uploading to DANDI" } From ec98679b49b4456d11430c21bb10f400356434e4 Mon Sep 17 00:00:00 2001 From: Garrett Date: Thu, 14 Sep 2023 10:10:08 -0700 Subject: [PATCH 17/23] Add description about staging derivation --- schemas/json/dandi/upload.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/schemas/json/dandi/upload.json b/schemas/json/dandi/upload.json index 4ece77105..366e702e9 100644 --- a/schemas/json/dandi/upload.json +++ b/schemas/json/dandi/upload.json @@ -1,7 +1,8 @@ { "properties": { "dandiset_id": { - "type": "string" + "type": "string", + "description": "The unique identifier for your dandiset. Will automatically determine whether to upload to the main or staging DANDI server." }, "cleanup": { "type": "boolean", From 59925b13604f7be0c2181def57cb88cce4a3e694 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 17:11:19 +0000 Subject: [PATCH 18/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/JSONSchemaForm.js | 7 +++++-- src/renderer/src/stories/JSONSchemaInput.js | 2 +- src/renderer/src/stories/pages/uploads/UploadsPage.js | 5 ++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index bbd554182..bfd84feed 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -115,7 +115,7 @@ pre { color: transparent; } - h4 { + h4 { margin: 0; margin-bottom: 5px; padding-bottom: 5px; @@ -852,7 +852,10 @@ export class JSONSchemaForm extends LitElement { return html`
- ${schema.description ? html`

Description

${unsafeHTML(schema.description)}

` : ""} + ${schema.description + ? html`

Description

+

${unsafeHTML(schema.description)}

` + : ""} ${this.#render(schema, this.resolved, this.#requirements)}
`; diff --git a/src/renderer/src/stories/JSONSchemaInput.js b/src/renderer/src/stories/JSONSchemaInput.js index 0a6a7ea07..f5293a61b 100644 --- a/src/renderer/src/stories/JSONSchemaInput.js +++ b/src/renderer/src/stories/JSONSchemaInput.js @@ -1,5 +1,5 @@ import { LitElement, css, html } from "lit"; -import { unsafeHTML } from 'lit/directives/unsafe-html.js' +import { unsafeHTML } from "lit/directives/unsafe-html.js"; import { FilesystemSelector } from "./FileSystemSelector"; import { BasicTable } from "./BasicTable"; diff --git a/src/renderer/src/stories/pages/uploads/UploadsPage.js b/src/renderer/src/stories/pages/uploads/UploadsPage.js index 2ed2331d1..7da82c9a6 100644 --- a/src/renderer/src/stories/pages/uploads/UploadsPage.js +++ b/src/renderer/src/stories/pages/uploads/UploadsPage.js @@ -19,10 +19,9 @@ import { DandiResults } from "../../DandiResults.js"; export const isStaging = (id) => parseInt(id) >= 100000; export async function uploadToDandi(info, type = "project" in info ? "" : "folder") { + const staging = isStaging(info.dandiset_id); // Automatically detect staging IDs - const staging = isStaging(info.dandiset_id) // Automatically detect staging IDs - - const whichAPIKey = staging ? 'staging_api_key' : 'main_api_key' + const whichAPIKey = staging ? "staging_api_key" : "main_api_key"; const api_key = global.data.DANDI?.api_keys?.[whichAPIKey]; if (!api_key) { From ff45354e34121d6a0ecdcb5450d9e9939eca8c70 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Thu, 14 Sep 2023 10:30:46 -0700 Subject: [PATCH 19/23] Update schemas/json/dandi/upload.json Co-authored-by: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> --- schemas/json/dandi/upload.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemas/json/dandi/upload.json b/schemas/json/dandi/upload.json index 366e702e9..40f130e47 100644 --- a/schemas/json/dandi/upload.json +++ b/schemas/json/dandi/upload.json @@ -2,7 +2,7 @@ "properties": { "dandiset_id": { "type": "string", - "description": "The unique identifier for your dandiset. Will automatically determine whether to upload to the main or staging DANDI server." + "description": "The unique identifier for your dandiset. Will automatically determine whether to upload to the main DANDI archive or the development staging server." }, "cleanup": { "type": "boolean", From a62a8e56c2a4bad945eed0881cfd54b6e1224e75 Mon Sep 17 00:00:00 2001 From: Garrett Date: Thu, 14 Sep 2023 13:34:47 -0700 Subject: [PATCH 20/23] Count fields properly (only interactive) --- src/renderer/src/stories/JSONSchemaForm.js | 41 +++++++++++++++++----- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index bfd84feed..d1a7967ea 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -484,18 +484,39 @@ export class JSONSchemaForm extends LitElement { } }; - #getRenderable = (schema = {}, required, path) => { + #getRenderable = (schema = {}, required, path, recursive = false) => { const entries = Object.entries(schema.properties ?? {}); - return entries.filter(([key, value]) => { + const isArrayOfArrays = (arr) => !!arr.find((v) => Array.isArray(v)) + + const flattenRecursedValues = (arr) => { + const newArr = [] + arr.forEach((o) => { + if (isArrayOfArrays(o)) newArr.push(...o) + else newArr.push(o) + }) + + return newArr + } + + const isRenderable = (key, value) => { + if (recursive && value.properties) return this.#getRenderable(value, required[key], [...path, key], true) + + else return [key, value] + } + + const res = entries.map(([key, value]) => { if (!value.properties && key === "definitions") return false; // Skip definitions if (this.ignore.includes(key)) return false; - if (this.showLevelOverride >= path.length) return true; - if (required[key]) return true; - if (this.#getLink([...this.#base, ...path, key])) return true; - if (!this.onlyRequired) return true; + if (this.showLevelOverride >= path.length) return isRenderable(key, value); + if (required[key]) return isRenderable(key, value); + if (this.#getLink([...this.#base, ...path, key])) return isRenderable(key, value); + if (!this.onlyRequired) return isRenderable(key, value); return false; - }); + }).filter(o => !!o) + + return flattenRecursedValues(res); // Flatten on the last pass + }; validateOnChange = () => {}; @@ -735,6 +756,7 @@ export class JSONSchemaForm extends LitElement { if (this.mode === "accordion" && hasMany) { const headerName = header(name); + this.#nestedForms[name] = new JSONSchemaForm({ identifier: this.identifier, schema: info, @@ -770,10 +792,11 @@ export class JSONSchemaForm extends LitElement { base: fullPath, }); - const accordion = new Accordion({ + + const accordion = new Accordion({ sections: { [headerName]: { - subtitle: `${this.#getRenderable(info, required[name], fullPath).length} fields`, + subtitle: `${this.#getRenderable(info, required[name], fullPath, true).length} fields`, content: this.#nestedForms[name], }, }, From 8b4291f710aaa26b24dd1536f4b78e34cec2a3cd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 20:36:18 +0000 Subject: [PATCH 21/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/JSONSchemaForm.js | 46 +++++++++++----------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index d1a7967ea..e1902a2a3 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -487,36 +487,36 @@ export class JSONSchemaForm extends LitElement { #getRenderable = (schema = {}, required, path, recursive = false) => { const entries = Object.entries(schema.properties ?? {}); - const isArrayOfArrays = (arr) => !!arr.find((v) => Array.isArray(v)) + const isArrayOfArrays = (arr) => !!arr.find((v) => Array.isArray(v)); const flattenRecursedValues = (arr) => { - const newArr = [] + const newArr = []; arr.forEach((o) => { - if (isArrayOfArrays(o)) newArr.push(...o) - else newArr.push(o) - }) + if (isArrayOfArrays(o)) newArr.push(...o); + else newArr.push(o); + }); - return newArr - } + return newArr; + }; const isRenderable = (key, value) => { - if (recursive && value.properties) return this.#getRenderable(value, required[key], [...path, key], true) - - else return [key, value] - } + if (recursive && value.properties) return this.#getRenderable(value, required[key], [...path, key], true); + else return [key, value]; + }; - const res = entries.map(([key, value]) => { - if (!value.properties && key === "definitions") return false; // Skip definitions - if (this.ignore.includes(key)) return false; - if (this.showLevelOverride >= path.length) return isRenderable(key, value); - if (required[key]) return isRenderable(key, value); - if (this.#getLink([...this.#base, ...path, key])) return isRenderable(key, value); - if (!this.onlyRequired) return isRenderable(key, value); - return false; - }).filter(o => !!o) + const res = entries + .map(([key, value]) => { + if (!value.properties && key === "definitions") return false; // Skip definitions + if (this.ignore.includes(key)) return false; + if (this.showLevelOverride >= path.length) return isRenderable(key, value); + if (required[key]) return isRenderable(key, value); + if (this.#getLink([...this.#base, ...path, key])) return isRenderable(key, value); + if (!this.onlyRequired) return isRenderable(key, value); + return false; + }) + .filter((o) => !!o); return flattenRecursedValues(res); // Flatten on the last pass - }; validateOnChange = () => {}; @@ -756,7 +756,6 @@ export class JSONSchemaForm extends LitElement { if (this.mode === "accordion" && hasMany) { const headerName = header(name); - this.#nestedForms[name] = new JSONSchemaForm({ identifier: this.identifier, schema: info, @@ -792,8 +791,7 @@ export class JSONSchemaForm extends LitElement { base: fullPath, }); - - const accordion = new Accordion({ + const accordion = new Accordion({ sections: { [headerName]: { subtitle: `${this.#getRenderable(info, required[name], fullPath, true).length} fields`, From 7e48322912da6cd8b4bcb5bfe532f3ffabc9897b Mon Sep 17 00:00:00 2001 From: Garrett Date: Thu, 14 Sep 2023 13:39:56 -0700 Subject: [PATCH 22/23] Fix table validation --- src/renderer/src/stories/JSONSchemaInput.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/stories/JSONSchemaInput.js b/src/renderer/src/stories/JSONSchemaInput.js index 81c5fd6ae..3b0b67376 100644 --- a/src/renderer/src/stories/JSONSchemaInput.js +++ b/src/renderer/src/stories/JSONSchemaInput.js @@ -189,7 +189,7 @@ export class JSONSchemaInput extends LitElement { // NOTE: This is likely an incorrect declaration of the table validation call validateOnChange: (key, parent, v) => { - return validateOnChange && this.#triggerValidation(key, this.form.tables[name], path); // this.form.validateOnChange(key, parent, fullPath, v); + return validateOnChange && ( this.onValidate ? this.onValidate() : this.form ? this.form.validateOnChange(key, parent, fullPath, v) : ''); }, onStatusChange: () => this.form?.checkStatus(), // Check status on all elements From cd85235dd1216025b3a630280241151a1edb04ef Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 20:40:20 +0000 Subject: [PATCH 23/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/JSONSchemaInput.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/stories/JSONSchemaInput.js b/src/renderer/src/stories/JSONSchemaInput.js index 3b0b67376..467cdbb65 100644 --- a/src/renderer/src/stories/JSONSchemaInput.js +++ b/src/renderer/src/stories/JSONSchemaInput.js @@ -189,7 +189,14 @@ export class JSONSchemaInput extends LitElement { // NOTE: This is likely an incorrect declaration of the table validation call validateOnChange: (key, parent, v) => { - return validateOnChange && ( this.onValidate ? this.onValidate() : this.form ? this.form.validateOnChange(key, parent, fullPath, v) : ''); + return ( + validateOnChange && + (this.onValidate + ? this.onValidate() + : this.form + ? this.form.validateOnChange(key, parent, fullPath, v) + : "") + ); }, onStatusChange: () => this.form?.checkStatus(), // Check status on all elements