diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index dcc3ca8263..07f3708085 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -18,6 +18,9 @@ on: env: SETUPTOOLS_SCM_PRETEND_VERSION_FOR_TILEDB: ${{ inputs.version }} + S3_BUCKET: ${{ vars.S3_BUCKET }} + TILEDB_NAMESPACE: ${{ vars.TILEDB_NAMESPACE }} + TILEDB_TOKEN: ${{ secrets.TILEDB_TOKEN }} jobs: build_wheels: @@ -46,7 +49,7 @@ jobs: uses: pypa/cibuildwheel@v2.18.1 env: CIBW_BUILD_VERBOSITY: 3 - CIBW_ENVIRONMENT_PASS_LINUX: SETUPTOOLS_SCM_PRETEND_VERSION_FOR_TILEDB + CIBW_ENVIRONMENT_PASS_LINUX: SETUPTOOLS_SCM_PRETEND_VERSION_FOR_TILEDB S3_BUCKET TILEDB_TOKEN TILEDB_NAMESPACE CIBW_ENVIRONMENT_MACOS: > CC=clang CXX=clang++ @@ -155,6 +158,6 @@ jobs: with: repository-url: https://test.pypi.org/legacy/ - # - name: Upload to pypi - # if: startsWith(github.ref, 'refs/tags/') - # uses: pypa/gh-action-pypi-publish@release/v1 + - name: Upload to pypi + if: startsWith(github.ref, 'refs/tags/') + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c497ebf92b..7bb1af3b77 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,11 @@ concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true +env: + S3_BUCKET: ${{ vars.S3_BUCKET }} + TILEDB_NAMESPACE: ${{ vars.TILEDB_NAMESPACE }} + TILEDB_TOKEN: ${{ secrets.TILEDB_TOKEN }} + jobs: build: runs-on: ${{ matrix.os }} diff --git a/tiledb/tests/test_cloud.py b/tiledb/tests/test_cloud.py new file mode 100644 index 0000000000..c09795556c --- /dev/null +++ b/tiledb/tests/test_cloud.py @@ -0,0 +1,71 @@ +import datetime +import os +import random +import string + +import numpy as np +import pytest + +import tiledb +from tiledb.tests.common import DiskTestCase + +tiledb_token = os.getenv("TILEDB_TOKEN") +tiledb_namespace = os.getenv("TILEDB_NAMESPACE") +s3_bucket = os.getenv("S3_BUCKET") + + +@pytest.mark.skipif( + not os.getenv("CI") and tiledb_token is None, + reason="No token was provided in a non-CI environment. Please set the TILEDB_TOKEN environment variable to run this test.", +) +class CloudTest(DiskTestCase): + def test_save_and_open_array_from_cloud(self): + config = tiledb.Config({"rest.token": tiledb_token}) + ctx = tiledb.Ctx(config=config) + + # Useful to include the datetime in the array name to handle multiple consecutive runs of the test. + # Random letters are added to the end to ensure that conflicts are avoided, especially in CI environments where multiple tests may run in parallel. + array_name = ( + datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S") + + "-" + + "".join(random.choice(string.ascii_letters) for _ in range(5)) + ) + uri = f"tiledb://{tiledb_namespace}/s3://{s3_bucket}/{array_name}" + + with tiledb.from_numpy(uri, np.random.rand(3, 2), ctx=ctx) as T: + self.assertTrue(tiledb.array_exists(uri, ctx=ctx)) + self.assertTrue( + T.schema + == tiledb.ArraySchema( + domain=tiledb.Domain( + tiledb.Dim( + name="__dim_0", + domain=(0, 2), + tile=3, + dtype="uint64", + filters=tiledb.FilterList([tiledb.ZstdFilter(level=-1)]), + ), + tiledb.Dim( + name="__dim_1", + domain=(0, 1), + tile=2, + dtype="uint64", + filters=tiledb.FilterList([tiledb.ZstdFilter(level=-1)]), + ), + ), + attrs=[ + tiledb.Attr( + name="", + dtype="float64", + var=False, + nullable=False, + enum_label=None, + ), + ], + cell_order="row-major", + tile_order="row-major", + sparse=False, + ) + ) + + tiledb.Array.delete_array(uri, ctx=ctx)