Closed corneliusroemer closed 1 year ago
Figured it out with help of ChatGPT (but would still be nice to dcoument):
npm run
(cargo
is actually modelled after npm
to some extent, so this is no coincidence)
So npm run view
is the equivalent of auspice view
There's a shortcut also available: npm start
that is the equivalent of npm run view
.
To pass arguments I need to add --
first: npm run view -- -h
This is how to test:
npm run view -- --datasetDir <AUSPICE_FOLDER_PATH>
You can also run ./auspice.js
, e.g. ./auspice.js view --datasetDir …
.
npm run
is not really equivalent to cargo run
; it's only running the shortcuts/aliases defined in package.json
, e.g.
It does some PATH and other env var manipulations before invoking the aliases, but these are rarely necessary.
The rough equivalent of pipx is npx; the former is vaguely modeled off the latter, but with substantial improvements IMO.
The Auspice install docs cover how to install "as a developer". Note that they recommend (and assume) you create a Conda environment so that the Node installation in use for Auspice is isolated. If you're managing Node installations another way (e.g. nvm), then you may not want to follow the recommendation to npm install --global .
.
Thanks! This dev install part https://docs.nextstrain.org/projects/auspice/en/stable/introduction/install.html#install-auspice-as-a-developer should be linked from dev docs - I didn't find it because I assumed docs would be user facing, not dev facing.
I'm following the dev installation but get an error:
CONDA_SUBDIR=osx-arm64 mamba create --name auspice nodejs=16
mamba activate auspice
conda config --env --set subdir osx-arm64
npm install --global .
with error:
npm ERR! WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
The dev docs do link to it, at the top:
I think that error indicates you have Webpack 4 not Webpack 5 (c.f. 7892c598fa305c2f1ee21c9aab5be01f15063c28 and efa51a77311099fd9eee9d1ab60a4f3cae88d4db). So that's interesting, because:
$ jq -r .dependencies.webpack package.json
^5.74.0
Doesn't explain what you're seeing, but this works fine for me:
mamba create --name auspice nodejs=16
conda activate auspice
npm install --global .
npm run build
The dev docs do link to it, at the top:
Ok, but hidden in a section that I skimmed because I was going to test not contribute. I was looking for a section titled: "Setting up Auspice for development and/or testing" ;)
Something is different on my system. I have nvm
installed, but which npm
returns what we'd expect:
❯ which npm
/opt/homebrew/Caskroom/miniforge/base/envs/auspice/bin/npm
❯ which node
/opt/homebrew/Caskroom/miniforge/base/envs/auspice/bin/node
Any ideas?
I think the next step is to interrogate npm about what Webpack version you got and why. Don't have immediate suggestions about what that why might be.
If you don't care about preserving the state of this problem, you could try running npm ci
to reinstall deps from scratch.
npm ci
is the solution, works! Thanks for the tip. Maybe we can add that to the docs too, for the noobs like me 🙃
Well, AFAIK, it shouldn't have been necessary with something like:
mamba create --name auspice nodejs=16
conda activate auspice
npm install --global .
npm run build
which is what's documented. So there's still something missing from our understanding here.
Ok, here's one issue, which may be related to yours: the current instructions for developers assume you already have a node_modules/
bootstrapped somehow.
rm -rf node_modules/
conda env remove --name auspice
mamba create --name auspice nodejs=16
conda activate auspice
npm install --global .
The last line, because of the prepare
and build
aliases,
tries to run Auspice before any deps are installed, yielding:
npm ERR! code 1
npm ERR! path /home/tom/nextstrain/auspice
npm ERR! command failed
npm ERR! command sh -c -- npm run build
npm ERR! > auspice@2.45.2 build
npm ERR! > node auspice.js build --verbose
npm ERR! node:internal/modules/cjs/loader:998
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: Cannot find module 'argparse'
npm ERR! Require stack:
npm ERR! - /home/tom/nextstrain/auspice/auspice.js
npm ERR! at Function.Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:841:27)
npm ERR! at Module.require (node:internal/modules/cjs/loader:1067:19)
npm ERR! at require (node:internal/modules/cjs/helpers:103:18)
npm ERR! at Object.<anonymous> (/home/tom/nextstrain/auspice/auspice.js:3:18)
npm ERR! at Module._compile (node:internal/modules/cjs/loader:1165:14)
npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1219:10)
npm ERR! at Module.load (node:internal/modules/cjs/loader:1043:32)
npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:878:12)
npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
npm ERR! code: 'MODULE_NOT_FOUND',
npm ERR! requireStack: [ '/home/tom/nextstrain/auspice/auspice.js' ]
npm ERR! }
npm ERR! A complete log of this run can be found in:
npm ERR! /home/tom/.npm/_logs/2023-03-23T22_43_28_039Z-debug-0.log
I'm trying to test @jameshadfield's PR #1655. The new feature applies only to very specific datasets, none of which are in the sample datasets that come with the heroku test build.
So I need to run auspice locally and pass in my own dataset through the CLI.
However, being a JS noob, I can't figure out how. And unfortunately the dev_docs.md don't seem to help me neither.
It would be nice if there was a simple section explaining how to run the auspice CLI based off the current code base, the equivalent of
pip install -e .
(which would also make the CLI entry point available in path), or something more likepipx
not putting it in path but allowing me to pass execute it once, something like that must exist!I want something like
cargo run
(Rust) where it runs the CLI off the current code base.