2525
2626from gretel_client .config import get_session_config , RunnerMode
2727from gretel_client .projects import create_project , get_project , Project
28+ from gretel_client .projects .artifact_handlers import open_artifact
2829from gretel_client .projects .jobs import ACTIVE_STATES , END_STATES , Status
2930from gretel_client .projects .records import RecordHandler
3031from gretel_trainer .relational .artifacts import ArtifactCollection
@@ -651,7 +652,7 @@ def run_transforms(
651652 if isinstance (data_source , pd .DataFrame ):
652653 data_source .to_csv (transforms_run_path , index = False )
653654 else :
654- with smart_open . open (data_source , "rb" ) as src , smart_open . open (
655+ with open_artifact (data_source , "rb" ) as src , open_artifact (
655656 transforms_run_path , "wb"
656657 ) as dest :
657658 shutil .copyfileobj (src , dest )
@@ -690,7 +691,10 @@ def run_transforms(
690691 for table , df in reshaped_tables .items ():
691692 filename = f"transformed_{ table } .csv"
692693 out_path = self ._output_handler .filepath_for (filename , subdir = run_subdir )
693- with smart_open .open (out_path , "wb" ) as dest :
694+ with open_artifact (
695+ out_path ,
696+ "wb" ,
697+ ) as dest :
694698 df .to_csv (
695699 dest ,
696700 index = False ,
@@ -899,7 +903,7 @@ def generate(
899903 synth_csv_path = self ._output_handler .filepath_for (
900904 f"synth_{ table } .csv" , subdir = run_subdir
901905 )
902- with smart_open . open (synth_csv_path , "wb" ) as dest :
906+ with open_artifact (synth_csv_path , "wb" ) as dest :
903907 synth_df .to_csv (
904908 dest ,
905909 index = False ,
@@ -1042,7 +1046,7 @@ def create_relational_report(self, run_identifier: str, filepath: str) -> None:
10421046 now = datetime .utcnow (),
10431047 run_identifier = run_identifier ,
10441048 )
1045- with smart_open . open (filepath , "w" ) as report :
1049+ with open_artifact (filepath , "w" ) as report :
10461050 html_content = ReportRenderer ().render (presenter )
10471051 report .write (html_content )
10481052
@@ -1054,8 +1058,8 @@ def _attach_existing_reports(self, run_id: str, table: str) -> None:
10541058 f"synthetics_cross_table_evaluation_{ table } .json" , subdir = run_id
10551059 )
10561060
1057- individual_report_json = json .loads (smart_open . open (individual_path ).read ())
1058- cross_table_report_json = json .loads (smart_open . open (cross_table_path ).read ())
1061+ individual_report_json = json .loads (open_artifact (individual_path ).read ())
1062+ cross_table_report_json = json .loads (open_artifact (cross_table_path ).read ())
10591063
10601064 self ._evaluations [table ].individual_report_json = individual_report_json
10611065 self ._evaluations [table ].cross_table_report_json = cross_table_report_json
0 commit comments