Skip to content

Commit

Permalink
add import to init (#621)
Browse files Browse the repository at this point in the history
* add import to init

* update tasks to fetch_tasks

* include tasks for backwards compat
  • Loading branch information
spencerseale authored Aug 2, 2024
1 parent 2cc40d3 commit 92beece
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/tiledb/cloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
from .notebook import upload_notebook_contents
from .notebook import upload_notebook_from_file
from .rest_api import models
from .tasks import fetch_results
from .tasks import fetch_results_pandas
from .tasks import fetch_tasks
from .tasks import last_sql_task
from .tasks import last_udf_task
from .tasks import task
Expand Down Expand Up @@ -86,5 +89,8 @@
"last_sql_task",
"last_udf_task",
"task",
"fetch_tasks",
"fetch_results",
"fetch_results_pandas",
"TileDBCloudError",
)
17 changes: 11 additions & 6 deletions src/tiledb/cloud/tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime
import uuid
from typing import TYPE_CHECKING, Any, Optional
from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence

from tiledb.cloud import array
from tiledb.cloud import client
Expand Down Expand Up @@ -37,18 +37,18 @@ def task(id, async_req=False):
raise tiledb_cloud_error.maybe_wrap(exc) from None


def tasks(
def fetch_tasks(
namespace=None,
array=None,
start=None,
end=datetime.datetime.utcnow(),
end=datetime.datetime.now(datetime.timezone.utc),
status=None,
page=None,
per_page=None,
async_req=False,
):
) -> Dict[str, Sequence[Dict[str, Any]]]:
"""
Fetch all tasks a user has access too
Fetch all tasks a user has access too.
:param str namespace: optional filter by namespace
:param str array: optional limit tasks to specific array
:param datetime start: optional start time for listing of tasks,
Expand All @@ -59,8 +59,9 @@ def tasks(
:param int page: optional page for pagenating results
:param int per_page: optional records to return per page
:param async_req: return future instead of results for async support
:return:
:return: Mapping of task data organized by task type.
"""

api_instance = client.build(rest_api.TasksApi)

if end is not None:
Expand Down Expand Up @@ -108,6 +109,10 @@ def tasks(
raise tiledb_cloud_error.maybe_wrap(exc) from None


# maintain backwards compatibility for tiledb.cloud.tasks.tasks
tasks = fetch_tasks


def last_sql_task():
"""
Fetch the last run sql array task
Expand Down
2 changes: 1 addition & 1 deletion tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_array_activity(self):
array.array_activity("tiledb://TileDB-Inc/quickstart_sparse")

def test_tasks(self):
self.assertIsNotNone(tasks.tasks(page=1, per_page=100))
self.assertIsNotNone(tasks.fetch_tasks(page=1, per_page=100))

def test_list_arrays(self):
self.assertIsNotNone(client.list_arrays().arrays)
Expand Down

0 comments on commit 92beece

Please sign in to comment.