4242from .blob_data import (
4343 BlobStorageData ,
4444 BlobType ,
45+ EverestBatchData ,
4546 MatrixStorageData ,
4647 ObservationReportData ,
4748 ScalingFactorsData ,
@@ -1416,13 +1417,31 @@ def save_blob(
14161417
14171418 @require_write
14181419 def save_batch_dataframes (self , dataframes : BatchDataframes ) -> None :
1420+ blob_dir = self ._path / BLOB_DATA_DIR
14191421 for df_name , df in dataframes .items ():
1420- if isinstance (df , pl .DataFrame ):
1421- df .write_parquet (self ._path / f"{ df_name } .parquet" )
1422+ if not isinstance (df , pl .DataFrame ):
1423+ continue
1424+ buf = io .BytesIO ()
1425+ df .write_parquet (buf )
1426+ data = buf .getvalue ()
1427+ BlobStorageData .save_blob (
1428+ name = df_name ,
1429+ data = data ,
1430+ blob_info = EverestBatchData (dataframe_name = df_name ),
1431+ file_type = "application/parquet" ,
1432+ storage = self ._storage ,
1433+ blob_dir = blob_dir ,
1434+ )
14221435
14231436 @property
14241437 def has_function_results (self ) -> bool :
1425- return (self ._path / "batch_objectives.parquet" ).exists ()
1438+ for meta in self .load_blobs (BlobType .EVEREST_BATCH_DATA ):
1439+ if (
1440+ isinstance (meta .blob_info , EverestBatchData )
1441+ and meta .blob_info .dataframe_name == "batch_objectives"
1442+ ):
1443+ return meta .file_size > 0
1444+ return False
14261445
14271446 @property
14281447 def has_gradient_results (self ) -> bool :
@@ -1433,10 +1452,13 @@ def has_gradient_results(self) -> bool:
14331452 info ["perturbation" ] != - 1 for _ , info in self .simulations_with_responses
14341453 )
14351454
1436- @staticmethod
1437- def _read_df_if_exists (path : Path ) -> pl .DataFrame | None :
1438- if path .exists ():
1439- return pl .read_parquet (path )
1455+ def _read_batch_dataframe (self , dataframe_name : str ) -> pl .DataFrame | None :
1456+ for meta in self .load_blobs (BlobType .EVEREST_BATCH_DATA ):
1457+ if (
1458+ isinstance (meta .blob_info , EverestBatchData )
1459+ and meta .blob_info .dataframe_name == dataframe_name
1460+ ):
1461+ return pl .read_parquet (io .BytesIO (self .load_blob (meta .uri )))
14401462 return None
14411463
14421464 @property
@@ -1533,7 +1555,7 @@ def perturbation_controls(self) -> pl.DataFrame | None:
15331555
15341556 @property
15351557 def batch_objectives (self ) -> pl .DataFrame | None :
1536- return self ._read_df_if_exists ( self . _path / "batch_objectives.parquet " )
1558+ return self ._read_batch_dataframe ( "batch_objectives" )
15371559
15381560 @property
15391561 def realization_objectives (self ) -> pl .DataFrame | None :
@@ -1570,7 +1592,7 @@ def realization_objectives(self) -> pl.DataFrame | None:
15701592
15711593 @property
15721594 def batch_constraints (self ) -> pl .DataFrame | None :
1573- return self ._read_df_if_exists ( self . _path / "batch_constraints.parquet " )
1595+ return self ._read_batch_dataframe ( "batch_constraints" )
15741596
15751597 @property
15761598 def realization_constraints (self ) -> pl .DataFrame | None :
@@ -1610,25 +1632,19 @@ def realization_constraints(self) -> pl.DataFrame | None:
16101632
16111633 @property
16121634 def batch_bound_constraint_violations (self ) -> pl .DataFrame | None :
1613- return self ._read_df_if_exists (
1614- self ._path / "batch_bound_constraint_violations.parquet"
1615- )
1635+ return self ._read_batch_dataframe ("batch_bound_constraint_violations" )
16161636
16171637 @property
16181638 def batch_input_constraint_violations (self ) -> pl .DataFrame | None :
1619- return self ._read_df_if_exists (
1620- self ._path / "batch_input_constraint_violations.parquet"
1621- )
1639+ return self ._read_batch_dataframe ("batch_input_constraint_violations" )
16221640
16231641 @property
16241642 def batch_output_constraint_violations (self ) -> pl .DataFrame | None :
1625- return self ._read_df_if_exists (
1626- self ._path / "batch_output_constraint_violations.parquet"
1627- )
1643+ return self ._read_batch_dataframe ("batch_output_constraint_violations" )
16281644
16291645 @property
16301646 def batch_objective_gradient (self ) -> pl .DataFrame | None :
1631- return self ._read_df_if_exists ( self . _path / "batch_objective_gradient.parquet " )
1647+ return self ._read_batch_dataframe ( "batch_objective_gradient" )
16321648
16331649 @property
16341650 def simulations (self ) -> list [tuple [int , EverestRealizationInfo ]]:
@@ -1686,7 +1702,7 @@ def perturbation_objectives(self) -> pl.DataFrame | None:
16861702
16871703 @property
16881704 def batch_constraint_gradient (self ) -> pl .DataFrame | None :
1689- return self ._read_df_if_exists ( self . _path / "batch_constraint_gradient.parquet " )
1705+ return self ._read_batch_dataframe ( "batch_constraint_gradient" )
16901706
16911707 @property
16921708 def perturbation_constraints (self ) -> pl .DataFrame | None :
0 commit comments