Skip to content

Commit

Permalink
Fix build tests
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed May 22, 2024
1 parent 013a883 commit edf8342
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nwb-guide.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scipy
from PyInstaller.utils.hooks import collect_data_files
from PyInstaller.utils.hooks import collect_all

datas = [('./src/paths.config.json', './src'), ('./package.json', '.')]
datas = [('./src/paths.config.json', '.'), ('./package.json', '.')]
binaries = []
hiddenimports = [
'email_validator',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"test:pipelines": "vitest pipelines",
"test:server": "pytest src/pyflask/tests/ -s -vv",
"wait5s": "node -e \"setTimeout(() => process.exit(0),5000)\"",
"test:executable": "concurrently -n EXE,TEST --kill-others --success first \"node tests/testPyinstallerExecutable.js --port 3434 --forever\" \"npm run wait5s && 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 wait5s && pytest src/pyflask/tests/ -s --target http://localhost:3434\"",
"test:coverage": "npm run coverage:app && npm run coverage:server",
"coverage:app": "npm run test:app -- --coverage",
"coverage:server": "pytest src/pyflask/tests/ -s --cov=pyflask --cov-report=xml",
Expand Down
3 changes: 2 additions & 1 deletion src/pyflask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
GUIDE_ROOT_FOLDER,
STUB_SAVE_FOLDER_PATH,
resource_path,
is_packaged
)

app = Flask(__name__)
Expand All @@ -42,7 +43,7 @@
LOG_FILE_PATH = Path(LOG_FOLDER, f"{timestamp}.log")

# Initialize API
package_json_file_path = resource_path("../package.json")
package_json_file_path = resource_path("package.json" if is_packaged() else "../package.json")
with open(file=package_json_file_path) as fp:
package_json = json.load(fp=fp)

Expand Down
1 change: 1 addition & 0 deletions src/pyflask/manageNeuroconv/info/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
GUIDE_ROOT_FOLDER,
STUB_SAVE_FOLDER_PATH,
resource_path,
is_packaged
)
9 changes: 9 additions & 0 deletions src/pyflask/manageNeuroconv/info/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
import sys
from pathlib import Path

def is_packaged():
deployed = True
try:
sys._MEIPASS # PyInstaller creates a temp folder and stores path in _MEIPASS
except Exception:
deployed = False

return deployed

def resource_path(relative_path):
"""Get absolute path to resource, works for dev and for PyInstaller"""
Expand All @@ -20,6 +28,7 @@ def resource_path(relative_path):
path_config = resource_path(
"paths.config.json"
) # NOTE: Must have pyflask for running the GUIDE as a whole, but errors for just the server

f = path_config.open()
data = json.load(f)
GUIDE_ROOT_FOLDER = Path(Path.home(), data["root"])
Expand Down

0 comments on commit edf8342

Please sign in to comment.