Skip to content

Commit

Permalink
run black on updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbesnard1 committed Feb 25, 2025
1 parent a19f4f3 commit 251cb2a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
10 changes: 4 additions & 6 deletions gedidb/core/gediprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,13 @@ def get_data(
raise ValueError(
f"Invalid query_type '{query_type}'. Must be 'bounding_box' or 'nearest'."
)

# Ensure return_type is valid
if return_type not in {"xarray", "dataframe"}:
raise ValueError(
f"Invalid return_type '{return_type}'. Must be either 'xarray' or 'dataframe'."
)

# Validation for bounding_box queries
if query_type == "bounding_box":
if geometry is None or not isinstance(geometry, gpd.GeoDataFrame):
Expand Down Expand Up @@ -372,13 +372,12 @@ def get_data(
logger.info("No data found for specified criteria.")
return None

metadata = self.get_available_variables()

if return_type == "xarray":
metadata = self.get_available_variables()
return self.to_xarray(scalar_data, metadata, profile_vars)
elif return_type == "dataframe":
return self.to_dataframe(scalar_data)

def to_dataframe(self, scalar_data: Dict[str, np.ndarray]) -> pd.DataFrame:
"""
Convert scalar and profile data dictionaries into a unified pandas DataFrame.
Expand Down Expand Up @@ -517,7 +516,6 @@ def to_xarray(
)
dataset = dataset.sortby("time")


self._attach_metadata(dataset, metadata)

return dataset
Expand Down
26 changes: 14 additions & 12 deletions gedidb/providers/tiledb_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(
local_path: Optional[str] = "./",
url: Optional[str] = None,
region: str = "eu-central-1",
credentials: Optional[dict] = None
credentials: Optional[dict] = None,
):

# Validate storage_type
Expand Down Expand Up @@ -65,17 +65,19 @@ def __init__(
f"Invalid 'storage_type': {storage_type}. Must be 'local' or 's3'."
)

def _initialize_s3_context(self, credentials: Optional[dict], url: str, region: str) -> tiledb.Ctx:
def _initialize_s3_context(
self, credentials: Optional[dict], url: str, region: str
) -> tiledb.Ctx:
config = {
"vfs.s3.endpoint_override": url,
"vfs.s3.region": region,
"py.init_buffer_bytes": "17179869184", # 2GB buffer
"sm.tile_cache_size": "17179869184", # 2GB cache
"sm.num_reader_threads": "128", # More parallel reads
"sm.num_tiledb_threads": "128",
"vfs.s3.max_parallel_ops": "64", # Maximize parallel S3 ops
"vfs.s3.use_virtual_addressing": "true",
}
"vfs.s3.endpoint_override": url,
"vfs.s3.region": region,
"py.init_buffer_bytes": "17179869184", # 2GB buffer
"sm.tile_cache_size": "17179869184", # 2GB cache
"sm.num_reader_threads": "128", # More parallel reads
"sm.num_tiledb_threads": "128",
"vfs.s3.max_parallel_ops": "64", # Maximize parallel S3 ops
"vfs.s3.use_virtual_addressing": "true",
}
return tiledb.Ctx(config)

# Add credentials if provided
Expand Down Expand Up @@ -172,7 +174,7 @@ def _query_array(
data = query.multi_index[
lat_min:lat_max, lon_min:lon_max, start_time:end_time
]

if len(data["shot_number"]) == 0:
return None, profile_vars

Expand Down

0 comments on commit 251cb2a

Please sign in to comment.