Skip to content

Commit

Permalink
Merge pull request #116 from fredo-dedup/julia-0.7
Browse files Browse the repository at this point in the history
Start port to julia 0.7
  • Loading branch information
davidanthoff authored Aug 9, 2018
2 parents 5bc3844 + 811248c commit ddc8837
Show file tree
Hide file tree
Showing 26 changed files with 97 additions and 112 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ deps/lib/
deps/npm-debug.log
.directory
.ipynb_checkpoints
deps/build.log
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ os:
- linux
- osx
julia:
- 0.6
- 0.7
- 1.0
notifications:
email: false
branches:
Expand Down
5 changes: 1 addition & 4 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
julia 0.6
Compat 0.9.1
julia 0.7
JSON
Requires
NodeJS
Expand All @@ -9,9 +8,7 @@ IteratorInterfaceExtensions 0.0.1
TableTraits 0.0.2
IterableTables
FileIO 0.9.1
Juno
DataValues
MacroTools
NamedTuples
URIParser
FilePaths
31 changes: 17 additions & 14 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- julia_version: 0.7
- julia_version: 1.0

platform:
- x86 # 32-bit
- x64 # 64-bit

## uncomment the following lines to allow failures on nightly julia
## (tests will run but not make your overall status red)
# matrix:
# allow_failures:
# - julia_version: latest

branches:
only:
Expand All @@ -15,19 +25,12 @@ notifications:
on_build_status_changed: false

install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$env:JULIA_URL,
"C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))

build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo();
Pkg.clone(pwd(), \"VegaLite\"); Pkg.build(\"VegaLite\")"
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- C:\projects\julia\bin\julia -e "Pkg.test(\"VegaLite\")"
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
1 change: 0 additions & 1 deletion deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ end)

# install NodeJS modules
using NodeJS
using Compat

run(Cmd(`$(npm_cmd()) install --production --no-bin-links --no-package-lock --no-optional`, dir=@__DIR__))

9 changes: 4 additions & 5 deletions src/VegaLite.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
__precompile__()

module VegaLite

using JSON, Compat, Requires, NodeJS, Rsvg, NamedTuples # 6s
using JSON, Requires, NodeJS, Rsvg # 6s
import Cairo
import IteratorInterfaceExtensions # 1s
import TableTraits # 0
using FileIO # 17s !!!
import DataValues # 1s
using DataValues # 1s
import MacroTools
using URIParser
using FilePaths
using REPL, Dates
using Random

# This import can eventually be removed, it currently just makes sure
# that the iterable tables integration for DataFrames and friends
Expand Down Expand Up @@ -84,7 +84,6 @@ include("dsl_vlplot_macro/dsl_vlplot_macro.jl")
include("dsl_str_macro/dsl_str_macro.jl")

include("rendering/render.jl")
include("rendering/juno_integration.jl")
include("rendering/io.jl")
include("rendering/show.jl")
include("rendering/fileio.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/dsl_helper_func/dsl_helper_func.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ layer(args...) = mkSpec(:vllayer, args...)
# dat is a special case, we want to interpret correctly cases where an
# iterable table is passed as an argument

getrealvalue(v::DataValues.DataValue) = isnull(v) ? nothing : get(v)
getrealvalue(v::DataValues.DataValue) = isna(v) ? nothing : get(v)
getrealvalue(v) = v

function vldata(args...; kwargs...)
Expand Down
24 changes: 12 additions & 12 deletions src/dsl_vlplot_macro/dsl_vlplot_macro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,21 @@ function fix_shortcuts(spec::Dict{String,Any}, positional_key::String)
if transform["from"]["data"] isa Dict && haskey(transform["from"]["data"], "url")
if transform["from"]["data"]["url"] isa AbstractPath
as_uri = string(URI(transform["from"]["data"]["url"]))
transform["from"]["data"]["url"] = is_windows() ? as_uri[1:5] * as_uri[7:end] : as_uri
transform["from"]["data"]["url"] = Sys.iswindows() ? as_uri[1:5] * as_uri[7:end] : as_uri
elseif transform["from"]["data"]["url"] isa URI
as_uri = string(transform["from"]["data"]["url"])
transform["from"]["data"]["url"] = is_windows() && transform["from"]["data"]["url"].scheme=="file" ? as_uri[1:5] * as_uri[7:end] : as_uri
transform["from"]["data"]["url"] = Sys.iswindows() && transform["from"]["data"]["url"].scheme=="file" ? as_uri[1:5] * as_uri[7:end] : as_uri
end
elseif transform["from"]["data"] isa AbstractPath
as_uri = string(URI(transform["from"]["data"]))
transform["from"]["data"] = Dict{String,Any}("url" => is_windows() ? as_uri[1:5] * as_uri[7:end] : as_uri)
transform["from"]["data"] = Dict{String,Any}("url" => Sys.iswindows() ? as_uri[1:5] * as_uri[7:end] : as_uri)
elseif transform["from"]["data"] isa URI
as_uri = string(transform["from"]["data"])
transform["from"]["data"] = Dict{String,Any}("url" => is_windows() && transform["from"]["data"].scheme=="file" ? as_uri[1:5] * as_uri[7:end] : as_uri)
transform["from"]["data"] = Dict{String,Any}("url" => Sys.iswindows() && transform["from"]["data"].scheme=="file" ? as_uri[1:5] * as_uri[7:end] : as_uri)
elseif TableTraits.isiterabletable(transform["from"]["data"])
it = IteratorInterfaceExtensions.getiterator(transform["from"]["data"])

recs = [Dict{String,Any}(string(c[1])=>isa(c[2], DataValues.DataValue) ? (isnull(c[2]) ? nothing : get(c[2])) : c[2] for c in zip(keys(r), values(r))) for r in it]
recs = [Dict{String,Any}(string(c[1])=>isa(c[2], DataValues.DataValue) ? (isna(c[2]) ? nothing : get(c[2])) : c[2] for c in zip(keys(r), values(r))) for r in it]

transform["from"]["data"] = Dict{String,Any}("values" => recs)
end
Expand All @@ -115,21 +115,21 @@ function fix_shortcuts(spec::Dict{String,Any}, positional_key::String)
if new_spec["data"] isa Dict && haskey(new_spec["data"], "url")
if new_spec["data"]["url"] isa AbstractPath
as_uri = string(URI(new_spec["data"]["url"]))
new_spec["data"]["url"] = is_windows() ? as_uri[1:5] * as_uri[7:end] : as_uri
new_spec["data"]["url"] = Sys.iswindows() ? as_uri[1:5] * as_uri[7:end] : as_uri
elseif new_spec["data"]["url"] isa URI
as_uri = string(new_spec["data"]["url"])
new_spec["data"]["url"] = is_windows() && new_spec["data"]["url"].scheme=="file" ? as_uri[1:5] * as_uri[7:end] : as_uri
new_spec["data"]["url"] = Sys.iswindows() && new_spec["data"]["url"].scheme=="file" ? as_uri[1:5] * as_uri[7:end] : as_uri
end
elseif new_spec["data"] isa AbstractPath
as_uri = string(URI(new_spec["data"]))
new_spec["data"] = Dict{String,Any}("url" => is_windows() ? as_uri[1:5] * as_uri[7:end] : as_uri)
new_spec["data"] = Dict{String,Any}("url" => Sys.iswindows() ? as_uri[1:5] * as_uri[7:end] : as_uri)
elseif new_spec["data"] isa URI
as_uri = string(new_spec["data"])
new_spec["data"] = Dict{String,Any}("url" => is_windows() && new_spec["data"].scheme=="file" ? as_uri[1:5] * as_uri[7:end] : as_uri)
new_spec["data"] = Dict{String,Any}("url" => Sys.iswindows() && new_spec["data"].scheme=="file" ? as_uri[1:5] * as_uri[7:end] : as_uri)
elseif TableTraits.isiterabletable(new_spec["data"])
it = IteratorInterfaceExtensions.getiterator(new_spec["data"])

recs = [Dict{String,Any}(string(c[1])=>isa(c[2], DataValues.DataValue) ? (isnull(c[2]) ? nothing : get(c[2])) : c[2] for c in zip(keys(r), values(r))) for r in it]
recs = [Dict{String,Any}(string(c[1])=>isa(c[2], DataValues.DataValue) ? (isna(c[2]) ? nothing : get(c[2])) : c[2] for c in zip(keys(r), values(r))) for r in it]

new_spec["data"] = Dict{String,Any}("values" => recs)
end
Expand All @@ -142,7 +142,7 @@ function convert_curly_style_array(exprs, positional_key)
res = Expr(:vect)

for ex in exprs
if ex isa Expr && ex.head==:cell1d
if ex isa Expr && ex.head==:braces
push!(res.args, :( Dict{String,Any}($(convert_curly_style(ex.args, positional_key)...)) ))
else
push!(res.args, ex)
Expand All @@ -156,7 +156,7 @@ function convert_curly_style(exprs, positional_key)
new_exprs=[]
for ex in exprs
if ex isa Expr && ex.head==:(=)
if ex.args[2] isa Expr && ex.args[2].head==:cell1d
if ex.args[2] isa Expr && ex.args[2].head==:braces
push!(new_exprs, :( $(string(ex.args[1])) => Dict{String,Any}($(convert_curly_style(ex.args[2].args, positional_key)...)) ))
elseif ex.args[2] isa Expr && ex.args[2].head==:vect
push!(new_exprs, :( $(string(ex.args[1])) => $(convert_curly_style_array(ex.args[2].args, positional_key)) ))
Expand Down
4 changes: 2 additions & 2 deletions src/dsl_vlplot_macro/shorthandparser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ function tokenize_shorthand(s::AbstractString)
end
push!(tokens,s[i:i])
curr_start = nextind(s,i)
elseif !(isalnum(s[i]) || s[i] in ('_'))
elseif !(isletter(s[i]) || isnumeric(s[i]) || s[i] in ('_'))
throw(ArgumentError("Invalid shortcut string"))
end

i = nextind(s,i)

if i>endof(s)
if i>lastindex(s)
if i>curr_start
push!(tokens,s[curr_start:prevind(s,i)])
end
Expand Down
4 changes: 2 additions & 2 deletions src/rendering/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ Load a vega-lite specification from a file with name `filename`. Returns
a `VLSpec` object.
"""
function loadspec(filename::AbstractString)
s = readstring(filename)
s = read(filename, String)
return VLSpec{:plot}(JSON.parse(s))
end

function loadvgspec(filename::AbstractString)
s = readstring(filename)
s = read(filename, String)
return VGSpec(JSON.parse(s))
end

Expand Down
19 changes: 0 additions & 19 deletions src/rendering/juno_integration.jl

This file was deleted.

10 changes: 5 additions & 5 deletions src/rendering/render.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,23 +190,23 @@ end
opens a browser tab with the given html file
"""
function launch_browser(tmppath::String)
if is_apple()
if Sys.isapple()
run(`open $tmppath`)
elseif is_windows()
elseif Sys.iswindows()
run(`cmd /c start $tmppath`)
elseif is_linux()
elseif Sys.islinux()
run(`xdg-open $tmppath`)
end
end


function Base.display(d::Base.REPL.REPLDisplay, plt::VLSpec{:plot})
function Base.display(d::REPL.REPLDisplay, plt::VLSpec{:plot})
# checkplot(plt)
tmppath = writehtml_full(JSON.json(plt.params))
launch_browser(tmppath) # Open the browser
end

function Base.display(d::Base.REPL.REPLDisplay, plt::VGSpec)
function Base.display(d::REPL.REPLDisplay, plt::VGSpec)
tmppath = write_vg_html_full(JSON.json(plt.params))
launch_browser(tmppath) # Open the browser
end
26 changes: 14 additions & 12 deletions src/rendering/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ end
function convert_to_svg(v::VLSpec{:plot})
data = JSON.json(v.params)
script_path = joinpath(@__DIR__, "compilesvg.js")
p_out, p_in, p = readandwrite(`$(nodejs_cmd()) $script_path`)
write(p_in, data)
flush(p_in)
close(p_in)
res = readstring(p_out)
close(p_out)
p = open(`$(nodejs_cmd()) $script_path`, "r+")
writer = @async begin
write(p, data)
close(p.in)
end
reader = @async read(p, String)
wait(p)
res = fetch(reader)
if p.exitcode!=0
throw(ArgumentError("Invalid spec"))
end
Expand All @@ -26,13 +27,14 @@ end
function convert_to_svg(v::VGSpec)
data = JSON.json(v.params)
script_path = joinpath(@__DIR__, "compilevg2svg.js")
p_out, p_in, p = readandwrite(`$(nodejs_cmd()) $script_path`)
write(p_in, data)
flush(p_in)
close(p_in)
res = readstring(p_out)
close(p_out)
p = open(`$(nodejs_cmd()) $script_path`, "r+")
writer = @async begin
write(p, data)
close(p.in)
end
reader = @async read(p, String)
wait(p)
res = fetch(reader)
if p.exitcode!=0
throw(ArgumentError("Invalid spec"))
end
Expand Down
2 changes: 1 addition & 1 deletion src/schema/func_definition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const jl2sp = Dict( (v,k) for (k,v) in sp2jl)
### conversion between property name in VegaLite and julia function name
jlfunc(vln::String) = jlfunc(Symbol(vln))
jlfunc(vln::Symbol) = Symbol("vl" * string(vln))
vlname(fn::Symbol) = replace(string(fn), r"^vl", "")
vlname(fn::Symbol) = replace(string(fn), r"^vl"=>"")


### step 1 : build a dict linking SpecDefs to (possibly several) parent SpecDef
Expand Down
4 changes: 2 additions & 2 deletions src/schema/func_documentation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
###################################################################

function prettydesc(desc::String)
res = replace(desc, "\n", " ") # remove all CR because they break formatting
res = replace(res, "__", "*") # markdown italic compatibilty issue ?
res = replace(desc, "\n"=>" ") # remove all CR because they break formatting
res = replace(res, "__"=>"*") # markdown italic compatibilty issue ?
res
end

Expand Down
Loading

0 comments on commit ddc8837

Please sign in to comment.