Skip to content

Commit

Permalink
Re-enable automatic upload to pypi (#2034)
Browse files Browse the repository at this point in the history
* Re-enable automatic upload to pypi
* Add test against tiledb://

---------

Co-authored-by: Agisilaos Kounelis <[email protected]>
  • Loading branch information
dudoslav and kounelisagis authored Oct 3, 2024
1 parent a1b6335 commit a6e1249
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -46,7 +49,7 @@ jobs:
uses: pypa/[email protected]
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++
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
71 changes: 71 additions & 0 deletions tiledb/tests/test_cloud.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a6e1249

Please sign in to comment.