kwatmdphd / clean.jl Goto Github PK
View Code? Open in Web Editor NEWCommand-line program for cleaning ๐
Command-line program for cleaning ๐
Last two VSCode commits have messed up with the repo, please revert master to 41ae791
Maybe, it is supposed to be so but it takes 2 minutes to clean a notebook with 5 non-empty Julia cells (and any other except an empty one)
$ time clean_ipynb 5\ Conditionals\ and\ Recursion.ipynb
5 Conditionals and Recursion.ipynb
clean_ipynb 5\ Conditionals\ and\ Recursion.ipynb 131,02s user 1,03s system 99% cpu 2:12,97 total
Version info:
It would be good to add an option to exit with an error code if some cleaning was needed. A bit like Prettier's --check
option.
Thanks ;)
In my opinion a progressbar like would be desirable to ensure the user nothing has crashed yet
A sample implementation
can be found here
curl https://raw.githubusercontent.com/KwatMDPhD/ComputationalEnvironment.how/main/JuliaFormatter.toml > ~/.JuliaFormatter.toml
@Joonalai 's request
Hi,
I've just tried to run the following command to install Clean.jl and I run into this error:
julia --project --eval "using Pkg; Pkg.instantiate()"
โ Error: Could not parse entry for `deps`
โ @ Pkg.Types /build/julia-CrxBG0/julia-1.5.3+dfsg/usr/share/julia/stdlib/v1.5/Pkg/src/manifest.jl:146
ERROR: MethodError: no method matching get(::Pair{String,Any}, ::String, ::Nothing)
Closest candidates are:
get(::REPL.Terminals.TTYTerminal, ::Any, ::Any) at /build/julia-CrxBG0/julia-1.5.3+dfsg/usr/share/julia/stdlib/v1.5/REPL/src/Terminals.jl:161
get(::Base.EnvDict, ::AbstractString, ::Any) at env.jl:80
get(::IdDict{K,V}, ::Any, ::Any) where {K, V} at iddict.jl:86
...
Stacktrace:
[1] Dict{Base.UUID,Pkg.Types.PackageEntry}(::Dict{String,Any}) at /build/julia-CrxBG0/julia-1.5.3+dfsg/usr/share/julia/stdlib/v1.5/Pkg/src/manifest.jl:135
[2] read_manifest(::String) at /build/julia-CrxBG0/julia-1.5.3+dfsg/usr/share/julia/stdlib/v1.5/Pkg/src/manifest.jl:177
[3] Pkg.Types.EnvCache(::Nothing) at /build/julia-CrxBG0/julia-1.5.3+dfsg/usr/share/julia/stdlib/v1.5/Pkg/src/Types.jl:299
[4] EnvCache at /build/julia-CrxBG0/julia-1.5.3+dfsg/usr/share/julia/stdlib/v1.5/Pkg/src/Types.jl:279 [inlined]
[5] Pkg.Types.Context() at ./util.jl:438
[6] #instantiate#169 at /build/julia-CrxBG0/julia-1.5.3+dfsg/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:791 [inlined]
[7] instantiate() at /build/julia-CrxBG0/julia-1.5.3+dfsg/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:791
[8] top-level scope at none:1
I'm a real newbie as Julia is concerned.
Any help would be great
Best
continous delivery with travis CI etc. would ensure that a merged pull request is really working (from the syntax part)
and maybe this could be combined with hosting the package on pypi.org
Traceback (most recent call last):
File "/Users/cls/anaconda3/lib/python3.7/site-packages/click/termui.py", line 372, in style
bits.append('\033[%dm' % (_ansi_colors.index(fg) + 30))
ValueError: tuple.index(x): x not in tuple
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/cls/anaconda3/bin/clean_ipynb", line 11, in <module>
sys.exit(command_line_interface())
File "/Users/cls/anaconda3/lib/python3.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/cls/anaconda3/lib/python3.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/cls/anaconda3/lib/python3.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/cls/anaconda3/lib/python3.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/cls/anaconda3/lib/python3.7/site-packages/clean_ipynb/command_line_interface.py", line 27, in command_line_interface
secho(ipynb_file_path, bg="black", fg="bright_green")
File "/Users/cls/anaconda3/lib/python3.7/site-packages/click/termui.py", line 420, in secho
return echo(style(text, **styles), file=file, nl=nl, err=err, color=color)
File "/Users/cls/anaconda3/lib/python3.7/site-packages/click/termui.py", line 374, in style
raise TypeError('Unknown color %r' % fg)
TypeError: Unknown color 'bright_green'
Hello, I want to use clean_ipynb.
But I am getting an error.
how to fix it?
clean_ipynb/clean_ipynb.py", line 120, in clean_ipynb_cell
rem_extra_new_line = clean_lines[-2][:-1]
My team uses https://pre-commit.com to automatically run linters and formatters on all of our code. I'm looking for something to run this on jupyter notebooks as well which is why I ran across your project.
As part of our pre-commit process we run
isort
autoflake
black
whitespace checks
it occurs to me that others may run different combinations of these. It would be great if your project could provide a way to generically run a set of linters on each notebook block.
@KwatME Most of the people who might want to use this tool actually are interested in formatting the python code aspects. Clearing the output might not be of their interest since once they push their code to repo / share their code somewhere they want to show their results too (i.e, plots or output's like accuracy etc.). Thus I think default should be not clearing output & clearing output can be enabled through flag
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.