diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..f6824e5 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,42 @@ +name: Linux + +on: + - push + - pull_request + +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "1" + os: + - ubuntu-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - name: Cache artifacts + uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + env: + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} + - uses: julia-actions/julia-uploadcodecov@latest + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/linux_nightly.yml b/.github/workflows/linux_nightly.yml new file mode 100644 index 0000000..ccf09f7 --- /dev/null +++ b/.github/workflows/linux_nightly.yml @@ -0,0 +1,42 @@ +name: Linux nightly + +on: + - push + - pull_request + +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "nightly" + os: + - ubuntu-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - name: Cache artifacts + uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + env: + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} + - uses: julia-actions/julia-uploadcodecov@latest + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml new file mode 100644 index 0000000..472f37f --- /dev/null +++ b/.github/workflows/mac.yml @@ -0,0 +1,42 @@ +name: Mac OS X + +on: + - push + - pull_request + +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "1" + os: + - macOS-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - name: Cache artifacts + uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + env: + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} + - uses: julia-actions/julia-uploadcodecov@latest + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/mac_nightly.yml b/.github/workflows/mac_nightly.yml new file mode 100644 index 0000000..2b935c5 --- /dev/null +++ b/.github/workflows/mac_nightly.yml @@ -0,0 +1,42 @@ +name: Mac OS X nightly + +on: + - push + - pull_request + +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "nightly" + os: + - macOS-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - name: Cache artifacts + uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + env: + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} + - uses: julia-actions/julia-uploadcodecov@latest + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..cda0981 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,42 @@ +name: Windows + +on: + - push + - pull_request + +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "1" + os: + - windows-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - name: Cache artifacts + uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + env: + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} + - uses: julia-actions/julia-uploadcodecov@latest + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/windows_nightly.yml b/.github/workflows/windows_nightly.yml new file mode 100644 index 0000000..0e49b26 --- /dev/null +++ b/.github/workflows/windows_nightly.yml @@ -0,0 +1,42 @@ +name: Windows nightly + +on: + - push + - pull_request + +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "nightly" + os: + - windows-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - name: Cache artifacts + uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + env: + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} + - uses: julia-actions/julia-uploadcodecov@latest + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index 16ffb27..f6fe967 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,25 @@  +
+ # cmap.jl CMAP.jl is the Julia client for Simons CMAP project. It provides access to the Simons CMAP database where various ocean data sets are hosted. These data sets include multi decades of remote sensing observations (satellite), numerical model estimates, and field expeditions. -This package is adopted from [pycmap](https://github.com/simonscmap/pycmap), which is the python client of Simons CMAP ecosystem. +This package is adopted from [pycmap](https://github.com/simonscmap/pycmap), which is the python client of Simons CMAP ecosystem. ## Documentation @@ -13,7 +28,7 @@ To be filled out. ## Usage example 1. Set your Simons API key. - + To make API requests, you need to get an API key from [Simons CMAP website](https://simonscmap.com). Once you have your API key, run the following command to store the API key on your local machine: ```julia @@ -27,20 +42,20 @@ To be filled out. datasets() ``` -1. Retrieve a subset of sea surface temperature measured by satellite. - +1. Retrieve a subset of sea surface temperature measured by satellite. + ```julia space_time( - table = "tblArgoMerge_REP", - variable = "argo_merge_salinity_adj", - dt1 = "2015-05-01", - dt2 = "2015-05-30", - lat1 = 28.1, - lat2 = 35.4, - lon1 = -71.3, - lon2 = -50, - depth1 = 0, + table = "tblArgoMerge_REP", + variable = "argo_merge_salinity_adj", + dt1 = "2015-05-01", + dt2 = "2015-05-30", + lat1 = 28.1, + lat2 = 35.4, + lon1 = -71.3, + lon2 = -50, + depth1 = 0, depth2 = 100 - ) + ) ``` diff --git a/src/rest.jl b/src/rest.jl index 885dc3c..88990ef 100644 --- a/src/rest.jl +++ b/src/rest.jl @@ -72,10 +72,19 @@ get_api_key() """ function get_api_key() keyFile = api_key_fname() - if ~isfile(keyFile) - error("API Key file not found. The following command will register the API key:\n\nset_api_key(key::String)\n\n") - end - return DataFrame(CSV.File(keyFile))[1, 1] + if isfile(keyFile) + return DataFrame(CSV.File(keyFile))[1, 1] + elseif haskey(ENV, "CMAP_API_KEY") + return ENV["CMAP_API_KEY"] + else + error(""" + API Key file not found. The following command will register the API key: + + ``` + set_api_key("Your API Key here") + ``` + """) + end end