Skip to content

Conversation

jana-selva
Copy link

@jana-selva jana-selva commented Sep 16, 2025

Closes #245

assert _collect_all_names(poems_root) == expected_names


def test_infer_path_onprem(backend_aware_bucketfs_params):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backend_aware_bucketfs_params returns SaaS or on-prem parameters, so if you specifically want to test on-prem, you need to skip SaaS. Alternatively, we could also think about, only having one test and check on the inferred path, if we can upload files to the path.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote to keep two tests, as the checks in one test would become more complex.....

saas_database_id: str | None = None,
saas_database_name: str | None = None,
saas_token: str | None = None,
) -> str:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is probably better to return the StorageBackend enum than a string.

Copy link

@ckunki ckunki Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, enum StorageBackend is part of notebook-connector, which BFSPY does not depend on (an should not!).

We could decide to implement another enum here, though.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the StorageBackend in this repo. It already exist.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
59.3% Coverage on New Code (required ≥ 80%)
3 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

bucketfs_user=backend_aware_bucketfs_params["username"],
bucketfs_password=backend_aware_bucketfs_params["password"],
path_in_bucket="onpremtest/",
bucketfs_use_https=backend_aware_bucketfs_params["verify"],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail if a backend other than onprem is selected.

Compare

all in pytest-plugins/pytest-backend

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - please excuse me.
I probably was wrong.
I didn't notice that you test case should only be executed onprem, but skipped on saas.

I now replaced fixture backend by use_onprem which should serve this purpose in my suggestion above.
Still, the test case needs to call pytest.skip() by himself.

)


class StorageBackend(Enum):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @ahsimb said: This probably could go to production code.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or simply use StorageBackend, maybe making it public by importing in bucketfs/__init__.py.

pat=saas_token,
path=path_in_bucket,
)
else:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, for a late comment. I think it might be useful to also include the Mounted BucketFS path here (and in the infer_backend). This backend is just a file path that can be used by either a UDF or for testing. See build_path.
The ValueError would probably be "Unsupported backend". Insufficient parameters would be thrown by the infer_backend. If it was happy with the parameters, this must be some kind of a new backend, this function is unaware of or really doesn't want to support. This is a very small thing of course.

saas_database_id="dbid",
saas_token="token",
)
assert result == "saas"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compare to the enum

Co-authored-by: Christoph Kuhnke <[email protected]>
Co-authored-by: Christoph Kuhnke <[email protected]>
Co-authored-by: Mikhail Beck <[email protected]>
Comment on lines 108 to 113
def test_infer_path_onprem(backend, backend_aware_bucketfs_params):
"""
Creates the PathLike and validates it.
"""
if backend == "saas":
pytest.skip()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_infer_path_onprem(backend, backend_aware_bucketfs_params):
"""
Creates the PathLike and validates it.
"""
if backend == "saas":
pytest.skip()
def test_infer_path_onprem(backend_aware_bucketfs_params, use_onprem):
"""
Creates the PathLike and validates it.
"""
if not use_onprem:
pytest.skip()

bucketfs_user=backend_aware_bucketfs_params["username"],
bucketfs_password=backend_aware_bucketfs_params["password"],
path_in_bucket="onpremtest/",
bucketfs_use_https=backend_aware_bucketfs_params["verify"],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - please excuse me.
I probably was wrong.
I didn't notice that you test case should only be executed onprem, but skipped on saas.

I now replaced fixture backend by use_onprem which should serve this purpose in my suggestion above.
Still, the test case needs to call pytest.skip() by himself.

Comment on lines 136 to 143
def test_infer_path_saas(
backend, saas_host, saas_pat, saas_account_id, backend_aware_saas_database_id
):
"""
Creates the SaasBucket with fixture details realted to Saas and validates it.
"""
if backend != "saas":
pytest.skip("The test runs only with SaaS database")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_infer_path_saas(
backend, saas_host, saas_pat, saas_account_id, backend_aware_saas_database_id
):
"""
Creates the SaasBucket with fixture details realted to Saas and validates it.
"""
if backend != "saas":
pytest.skip("The test runs only with SaaS database")
def test_infer_path_saas(
use_saas, saas_host, saas_pat, saas_account_id, backend_aware_saas_database_id
):
"""
Creates the SaasBucket with fixture details realted to Saas and validates it.
"""
if not use_saas:
pytest.skip("The test runs only with SaaS database")

Co-authored-by: Christoph Kuhnke <[email protected]>
Co-authored-by: Christoph Kuhnke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add backend inference for the Path-API
5 participants