Comments (3)
This is also something I've encountered, but never looked into "fixing".
It shouldn't be too hard to take this json object stream of status data and turn it into a nice loading CLI spinner + progress status/bar or something, using \r
:
~/Desktop
▶ cat test.js
process.stdout.write('one\r')
process.stdout.write('two\n')
~/Desktop
▶ node test.js
two
However, the lower level object stream is still required for use within Node, and it only makes sense to do \r
when using bionode programs interactively on CLI - so there needs to be some way to turn on the "user friendly status" form, but only when used from CLI. Perhaps an option in the API that is default turned on from within CLI code.
I would suggest we put together a standard form (i.e. json-schema) for "in progress JSON objects", and build a "logger" that wraps on top and has nice spinner/progress indicator.
Another option could be, have the "logger" tool take stdin
of the object form, then you could do something like:
bionode-ncbi download assembly guillardia theta | thelogger
I think last option is probably the best. The options for "user friendly mode" could simply pipe
the object stream into thelogger
(from within code so you don't need to ncbi ... | thelogger
- but could if you still wanted to).
The freezing is probably from the process not exiting after stream completes (I think it might actually be a duplex stream which is why it doesn't end - because stdin
can still exist)
from bionode-ncbi.
If you comment line 409 and change quiet: true
to quiet: false
in line 396 you already get a pretty decent loading bar. So, I do like the option to pass the function in line 409 to "thelogger". That way you have a simplified version (or user friendly) and a full logger that outputs all instances of download events that can be parsed by other scripts or programs.
The freezing does not occur if I do not use an interactive section of node, i.e., if I just run something like:
bionode-ncbi download assembly solenopsis invicta
from bionode-ncbi.
From a reusability point of view, I think bionode tools should always use NDJSON for STDIN and STDOUT. This standard allows developers to easily combine code and write pipelines. But from a UX point of view, it's sometimes ugly and confusing.
I think the general approach to solving this should be @thejmazz last example. That is, piping the NDJSON output to another tool that prettifies it, without modifying bionode-ncbi
code or behavior. This tool could be a NodeJS CLI that reuses one of the many progress bar libraries available. We could then reuse it with other bionode modules and CLI tools, in a way similar to what you can already do with GNU pv
.
However, in this particular case (as @tiagofilipe12 pointed out) bionode-ncbi
already has a pretty progress bar feature available internally due to downloads being handled by the nugget
dependency. So we could easily implement a --pretty
or --progress-bar
option to enable that feature on demand.
I'm happy to have a look at a PR that implements that feature. 😃
BTW, you can also just get the progress percentage on the same line with a bit of BASH scripting.
bionode-ncbi download assembly guillardia theta | json -ga progress | while read i; do echo -ne "\r$i"; done
from bionode-ncbi.
Related Issues (20)
- Implement efetch API
- Download the GFF file of the Cycas taitungensis mitochondrion HOT 9
- Uncaught, unspecified "error" event HOT 1
- How to look up metadata for an SRR file HOT 1
- Tests are broken because of NCBI side metadata changes (again) HOT 2
- rna_from_genomic instead of genomic.fna
- geo is not searchable HOT 5
- We need a smaller assembly from NCBI for testing HOT 3
- Git rid of git-lfs
- Error handling when NCBI connection is lost HOT 4
- User-friendly CLI
- Modularize lib structure.
- Output some warning to terminal when there is no output
- Add Blast API HOT 2
- Use progress bar on download HOT 5
- Downloading one run download the whole Bioproject
- TypeError: Cannot create property 'Run' on string ' ' HOT 1
- Dependencies error: Prototype Pollution (lodash dependencies)
- Unexpected error when running 'bionode' HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bionode-ncbi.