diff --git a/Project.toml b/Project.toml index 9265238..240d97e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ArgoData" uuid = "9eb831cf-c491-48dc-bed4-6aca718df73c" authors = ["gaelforget "] -version = "0.1.22" +version = "0.1.23" [deps] Bootstrap = "e28b5b4c-05e8-5b66-bc03-6f0c0a0a06e0" @@ -16,6 +16,7 @@ Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" MeshArrays = "cb8c808f-1acf-59a3-9d2b-6e38d009f683" NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab" +NetworkOptions = "ca575930-c2e3-43a9-ace4-1e988b2c1908" OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" @@ -24,19 +25,24 @@ YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" [weakdeps] Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d" +CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab" Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" +PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d" [extensions] ArgoDataCondaExt = ["Conda"] +ArgoDataCondaPkgExt = ["CondaPkg"] ArgoDataMakieExt = ["Makie"] ArgoDataPyCallExt = ["PyCall"] +ArgoDataPythonCallExt = ["PythonCall"] [compat] Bootstrap = "2" CSV = "0.10" Climatology = "0.5" Conda = "1" +CondaPkg = "0.2" DataFrames = "1" Downloads = "1" FTPClient = "1" @@ -46,8 +52,10 @@ JLD2 = "0.4, 0.5" Makie = "0.21" MeshArrays = "0.3" NCDatasets = "0.12, 0.13, 0.14" +NetworkOptions = "1" OrderedCollections = "1" PyCall = "1" +PythonCall = "0.9" Statistics = "1" YAML = "0.4" julia = "1.9" diff --git a/docs/Project.toml b/docs/Project.toml index 374c16d..0f7b15f 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,9 +1,9 @@ [deps] Climatology = "9e9a4d37-2d2e-41e3-8b85-f7978328d9c7" -Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d" +CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab" Dataverse = "9c0b9be8-e31e-490f-90fe-77697562404d" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" MITgcm = "dce5fa8e-68ce-4431-a242-9469c69627a0" NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab" PlutoSliderServer = "2fc8631c-6f24-4c5b-bca7-cbb509c42db4" -PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" +PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d" diff --git a/docs/make.jl b/docs/make.jl index 23a2107..7ed94c3 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -10,7 +10,7 @@ println(pth) run_argopy=false Sys.ARCH==:aarch64 ? run_argopy=false : nothing -if run_argopy +if false method="internal" if method=="external" tmpfile=joinpath(tempdir(),"pythonpath.txt") diff --git a/docs/src/examples.md b/docs/src/examples.md index 2305567..fed55d3 100644 --- a/docs/src/examples.md +++ b/docs/src/examples.md @@ -78,9 +78,18 @@ lst=Dataverse.file_list(doi) ## Argo via Python API -The python library called [argopy](https://github.com/euroargodev/argopy#readme) provides more ways to access, manipulate, and visualize [Argo data](https://argopy.readthedocs.io/en/latest/what_is_argo.html#what-is-argo). The notebook below demonstrates how you can : +The python library called [argopy](https://github.com/euroargodev/argopy#readme) provides more ways to access, manipulate, and visualize [Argo data](https://argopy.readthedocs.io/en/latest/what_is_argo.html#what-is-argo). -1. install `argopy` into `Julia` via [Conda.jl](https://github.com/JuliaPy/Conda.jl#readme) -2. use `argopy` from Julia via [PyCall.jl](https://github.com/JuliaPy/PyCall.jl#readme) +```@example argopy +using ArgoData, CondaPkg, PythonCall +ArgoData.conda(:argopy) +argopy=ArgoData.pyimport(:argopy) +println(argopy.status()) +``` + +```@example argopy +ds_fetcher=argopy.DataFetcher().float(pylist([6902746, 6902747, 6902757, 6902766])) +ds_points = ds_fetcher.to_xarray() +``` 👉 [Notebook](../Argo_argopy.html) 👈 [(code)](https://raw.githubusercontent.com/euroargodev/ArgoData.jl/master/examples/Argo_argopy.jl) diff --git a/ext/ArgoDataCondaPkgExt.jl b/ext/ArgoDataCondaPkgExt.jl new file mode 100644 index 0000000..cf77647 --- /dev/null +++ b/ext/ArgoDataCondaPkgExt.jl @@ -0,0 +1,14 @@ +module ArgoDataCondaPkgExt + +using CondaPkg, ArgoData + +function ArgoData.conda(flag=:argopy) + if flag==:argopy + CondaPkg.add("xarray",version=">=0.18,<2024.3") + CondaPkg.add("argopy") + else + error("unknown option") + end +end + +end diff --git a/ext/ArgoDataPythonCallExt.jl b/ext/ArgoDataPythonCallExt.jl new file mode 100644 index 0000000..d945aef --- /dev/null +++ b/ext/ArgoDataPythonCallExt.jl @@ -0,0 +1,23 @@ +module ArgoDataPythonCallExt + +using PythonCall, ArgoData +import ArgoData: NetworkOptions + +function ArgoData.pyimport(flag=:argopy) + if flag==:argopy +# @py import ssl +# p=ssl.get_default_verify_paths() +# string(p.cafile) +# println(cafile) + cafile=NetworkOptions.ca_roots_path() + ENV["SSL_CERT_FILE"] = cafile + PythonCall.pyimport("argopy") +# withenv("SSL_CERT_FILE"=>cafile) do +# PythonCall.pyimport("argopy") +# end + else + @warn "unknown flag value " + end +end + +end diff --git a/src/ArgoData.jl b/src/ArgoData.jl index 810e263..dcad204 100644 --- a/src/ArgoData.jl +++ b/src/ArgoData.jl @@ -10,11 +10,14 @@ include("GDAC.jl") include("MITprof.jl") include("MITprofAnalysis.jl") +import NetworkOptions + export GDAC, ArgoTools, GriddedFields export MITprof, MITprofAnalysis, MITprofStat export ProfileNative, ProfileStandard, MITprofStandard -conda(dev::String) = conda(:pyargo) -pyimport(dev::String) = pyimport(:pyargo) +function conda end +function pyimport end +function CondaPkgDev end end # module diff --git a/test/Project.toml b/test/Project.toml index b359f3a..2dacd82 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,10 +1,10 @@ [deps] Climatology = "9e9a4d37-2d2e-41e3-8b85-f7978328d9c7" -Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d" +CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab" MITgcm = "dce5fa8e-68ce-4431-a242-9469c69627a0" MeshArrays = "cb8c808f-1acf-59a3-9d2b-6e38d009f683" NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" +PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/runtests.jl b/test/runtests.jl index 0a747fc..291616e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,35 +1,22 @@ -run_argopy=false -Sys.ARCH==:aarch64 ? run_argopy=false : nothing -method="external" - -if run_argopy - if method=="external" - tmpfile=joinpath(tempdir(),"pythonpath.txt") - run(pipeline(`which python`,tmpfile)) - ENV["PYTHON"]=readline(tmpfile) - else #internal python path - ENV["PYTHON"]="" - end - using Pkg; Pkg.build("PyCall") - using PyCall, Conda -end - -## - using ArgoData, MeshArrays, Test using Climatology, MITgcm ENV["DATADEPS_ALWAYS_ACCEPT"]=true clim_path=Climatology.MITPROFclim_download() -readdir(clim_path) + +run_argopy=true +Sys.ARCH==:aarch64 ? run_argopy=false : nothing if run_argopy + using PythonCall, CondaPkg @testset "argopy" begin ArgoData.conda(:argopy) + println(CondaPkg.status()) argopy=ArgoData.pyimport(:argopy) + println(argopy.status()) - ds_fetcher=argopy.DataFetcher().float([6902746, 6902747, 6902757, 6902766]) + ds_fetcher=argopy.DataFetcher().float(pylist([6902746, 6902747, 6902757, 6902766])) ds_points = ds_fetcher.to_xarray() ds_profiles = ds_points.argo.point2profile()