Skip to content

Commit

Permalink
Patch config._config, not config.config (#682)
Browse files Browse the repository at this point in the history
* Defer loading of cloud.json file

This is achieved by deferring the initialization of low-level
instances until they are needed and by customizing attribute access
for the confg.py module.

* Explicitly call both the methods from the original constructor

* Fix failing config test, add more notes to config.py.

Also xfail two consistently failing task graph tests.

* Remove duplicated function
  • Loading branch information
sgillies authored Nov 15, 2024
1 parent e904d0b commit 58004c0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/tiledb/cloud/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
from tiledb.cloud.rest_api import models

default_host = "https://api.tiledb.com"
default_config_file = Path.joinpath(Path.home(), ".tiledb", "cloud.json")

# Starting with version 0.12.30, "config" is a dynamic attribute of
# this module. The actual state of the attribute is bound to "_config",
# which begins uninitialized. Looking up "config" from
# tiledb.cloud.config causes our stored configuration to be loaded
# just as needed.
_config = configuration.Configuration()
default_config_file = Path.joinpath(Path.home(), ".tiledb", "cloud.json")


def __getattr__(name):
Expand Down
4 changes: 4 additions & 0 deletions tests/taskgraphs/test_server_side.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import unittest

import pytest

import tiledb.cloud.taskgraphs as tg
from tiledb.cloud import dag
from tiledb.cloud.taskgraphs.server_executor import impl
Expand All @@ -19,6 +21,7 @@ def test_completed_graph(self) -> None:
self.assertEqual(connected.node("one").result(1), 1)
self.assertEqual(connected.node("two").result(1), 2)

@pytest.mark.xfail(reason="Server side error, graph not computed in expected time.")
def test_running_graph(self) -> None:
to_run = dag.DAG(mode=dag.Mode.BATCH)
one = to_run.submit(lambda: 1, name="one")
Expand All @@ -41,6 +44,7 @@ def second_func(inval):
self.assertIs(connected.node("two").status, tg.Status.SUCCEEDED)
self.assertIs(connected.status, tg.Status.SUCCEEDED)

@pytest.mark.xfail(reason="Server side error, graph not computed in expected time.")
def test_failing_graph(self) -> None:
to_run = dag.DAG(mode=dag.Mode.BATCH)
to_run.submit(lambda: 1 / 0, name="oops")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_login_bare_host(monkeypatch, tmp_path):
)
monkeypatch.setattr(
tiledb.cloud.client.config,
"config",
"_config",
tiledb.cloud.config.configuration.Configuration(),
)
monkeypatch.setattr(tiledb.cloud.client.config, "logged_in", False)
Expand Down

0 comments on commit 58004c0

Please sign in to comment.