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

Bug: loading PCP code looks for NPM #13

Open
slabasan opened this issue Apr 26, 2023 · 1 comment
Open

Bug: loading PCP code looks for NPM #13

slabasan opened this issue Apr 26, 2023 · 1 comment
Assignees
Labels
area-visualization Issues and PRs involving any of Thicket's provided visualizations priority-normal Normal priority issues and PRs type-bug Identifies bugs in issues and identifies bug fixes in PRs

Comments

@slabasan
Copy link
Collaborator

%load_ext thicket.vis.visualizations

     41 if not os.path.isfile(pkg_lock_file):
     42     if not check_npm():
---> 43         raise FileNotFoundError(_filenotfound_errmsg)
     44     else:
     45         npm_build(curr_dir)

FileNotFoundError: 
Cannot find NPM!
This is required to use thicket.vis!
Please install NPM and try again to import thicket.vis!
@slabasan slabasan added area-visualization Issues and PRs involving any of Thicket's provided visualizations priority-normal Normal priority issues and PRs type-bug Identifies bugs in issues and identifies bug fixes in PRs labels Apr 26, 2023
@ilumsden ilumsden self-assigned this Oct 17, 2023
@ilumsden
Copy link
Collaborator

@slabasan just noticed this issue and wanted to comment on it. This behavior is coming from my code in __init__.py, and it is fully intentional.

Due to the JavaScript code in thicket/vis/, Thicket is a mixed language project. The downside of mixed language projects (e.g., Python + JavaScript) is that it is almost impossible to track all required dependencies in a single unified way. This is only made worse by the current state of Python package management (super fragmented, with numerous ways to do any task). The code I have in thicket/vis/__init__.py is meant to help avoid a ton of issues with this.

Thicket has two sets of dependencies: (1) the Python dependencies contained in setup.py and (2) the JavaScript dependencies contained in thicket/vis/package.json. Since Thicket is primarily a Python project, we can use setup.py to allow any setuptools-compatible package manager (e.g., pip) to easily and automatically install dependencies. However, to install the JavaScript dependencies, we need to run npm install -y && npm run build within the thicket/vis/ directory.

There are two ways we could support installing Thicket's JavaScript dependencies.

The first way (not the one I've set up) is to require the user to manually go to thicket/vis/ and manually run the NPM commands above. This is alright (albeit tedious) for a local install. However, for a pip-based install of Thicket, this would require users to figure out exactly where pip installed Thicket.

The second way (which is what I'm using) involves automatically running NPM if it hasn't previously been run (indicated by the presence of package-lock.json in thicket/vis/). Unfortunately, due to the design and borderline required use of Python Wheels, we cannot do this at install time (i.e., when setup.py would be run). So, instead, my current approach runs NPM the very first time you try to import something from thicket.vis.

The error you show in your comment appears when you try to import thicket.vis for the first time, but you do not have NPM installed. The fix is to do exactly what the error message says and install NPM. Once you do that, the next import of thicket.vis will automatically install the JavaScript dependencies. This is a one-time cost, and it will only occur if you import thicket.vis. If you never import it, you'll never have to install the JavaScript dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-visualization Issues and PRs involving any of Thicket's provided visualizations priority-normal Normal priority issues and PRs type-bug Identifies bugs in issues and identifies bug fixes in PRs
Projects
None yet
Development

No branches or pull requests

3 participants