Skip to content

Better validation for account_name in Planetary Computer credential provider #479

Description

@kylebarron
from obstore.auth.planetary_computer import PlanetaryComputerCredentialProvider
from obstore.store import AzureStore
import pystac_client

catalog = pystac_client.Client.open(
    "https://planetarycomputer.microsoft.com/api/stac/v1/"
)
asset = catalog.get_collection("io-lulc-9-class").assets["geoparquet-items"]

account_name = asset.extra_fields["table:storage_options"]
credential_provider = PlanetaryComputerCredentialProvider(
    url=asset.href,
    account_name=account_name,
)
store = AzureStore(credential_provider=credential_provider)

This gives a confusing error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[16], line 6
      1 account_name = asset.extra_fields["table:storage_options"]
      2 credential_provider = PlanetaryComputerCredentialProvider(
      3     url=asset.href,
      4     account_name=account_name,
      5 )
----> 6 store = AzureStore(credential_provider=credential_provider)

TypeError: argument 'credential_provider': 'dict' object cannot be converted to 'PyString'

It's because

credential_provider.config
# {'account_name': {'account_name': 'pcstacitems'}, 'container_name': 'items'}

we should have validation that account_name is a str

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions