@@ -61,6 +61,9 @@ class OpenlayerClient(object):
6161 Your API key. You can find your workspace API key in your
6262 `account settings <https://docs.openlayer.com/documentation/how-to-guides/find-your-api-key>`_
6363 settings page.
64+ verbose : bool, default True
65+ Whether to print out success messages to the console. E.g., when data is
66+ successfully uploaded, a resource is staged, etc.
6467
6568 Examples
6669 --------
@@ -73,8 +76,9 @@ class OpenlayerClient(object):
7376 >>> client = openlayer.OpenlayerClient('YOUR_API_KEY_HERE')
7477 """
7578
76- def __init__ (self , api_key : str = None ):
79+ def __init__ (self , api_key : str = None , verbose : bool = True ):
7780 self .api = api .Api (api_key )
81+ self .verbose = verbose
7882
7983 if not os .path .exists (constants .OPENLAYER_DIR ):
8084 os .makedirs (constants .OPENLAYER_DIR )
@@ -164,9 +168,10 @@ def create_project(
164168 project_dir = os .path .join (constants .OPENLAYER_DIR , f"{ project .id } /staging" )
165169 os .makedirs (project_dir )
166170
167- print (
168- f"Created your project. Navigate to { project .links ['app' ]} to see it."
169- )
171+ if self .verbose :
172+ print (
173+ f"Created your project. Navigate to { project .links ['app' ]} to see it."
174+ )
170175 return project
171176
172177 def load_project (self , name : str ) -> Project :
@@ -216,7 +221,8 @@ def load_project(self, name: str) -> Project:
216221 if not os .path .exists (project_dir ):
217222 os .makedirs (project_dir )
218223
219- print (f"Found your project. Navigate to { project .links ['app' ]} to see it." )
224+ if self .verbose :
225+ print (f"Found your project. Navigate to { project .links ['app' ]} to see it." )
220226 return project
221227
222228 def create_or_load_project (
@@ -581,7 +587,8 @@ def commit(self, message: str, project_id: str, force: bool = False):
581587 with open (f"{ project_dir } /commit.yaml" , "w" , encoding = "UTF-8" ) as commit_file :
582588 yaml .dump (commit , commit_file )
583589
584- print ("Committed!" )
590+ if self .verbose :
591+ print ("Committed!" )
585592
586593 def _check_llm_and_no_outputs (self , project_dir : str ) -> bool :
587594 """Checks if the project's staging area contains an LLM and no outputs."""
@@ -638,7 +645,10 @@ def push(self, project_id: str, task_type: TaskType) -> Optional[ProjectVersion]
638645 project_version = ProjectVersion (json = response_body , client = self )
639646
640647 self ._post_push_cleanup (project_dir = project_dir )
641- print ("Pushed!" )
648+
649+ if self .verbose :
650+ print ("Pushed!" )
651+
642652 return project_version
643653
644654 def _ready_for_push (self , project_dir : str , task_type : TaskType ) -> bool :
@@ -802,7 +812,8 @@ def _stage_resource(
802812
803813 shutil .copytree (resource_dir , project_dir + "/" + resource_name )
804814
805- print (f"Staged the `{ resource_name } ` resource!" )
815+ if self .verbose :
816+ print (f"Staged the `{ resource_name } ` resource!" )
806817
807818 def load_project_version (self , version_id : str ) -> Project :
808819 """Loads an existing project version from the Openlayer platform. Can be used
@@ -957,10 +968,11 @@ def create_inference_pipeline(
957968 inference_pipeline_data , self .api .upload , self , task_type
958969 )
959970
960- print (
961- "Created your inference pipeline. Navigate to"
962- f" { inference_pipeline .links ['app' ]} to see it."
963- )
971+ if self .verbose :
972+ print (
973+ "Created your inference pipeline. Navigate to"
974+ f" { inference_pipeline .links ['app' ]} to see it."
975+ )
964976 return inference_pipeline
965977
966978 def load_inference_pipeline (
@@ -982,10 +994,11 @@ def load_inference_pipeline(
982994 inference_pipeline_data ["items" ][0 ], self .api .upload , self , task_type
983995 )
984996
985- print (
986- "Found your inference pipeline."
987- f" Navigate to { inference_pipeline .links ['app' ]} to see it."
988- )
997+ if self .verbose :
998+ print (
999+ "Found your inference pipeline."
1000+ f" Navigate to { inference_pipeline .links ['app' ]} to see it."
1001+ )
9891002 return inference_pipeline
9901003
9911004 def upload_reference_dataset (
@@ -1047,7 +1060,8 @@ def upload_reference_dataset(
10471060 storage_uri_key = "referenceDatasetUri" ,
10481061 method = "PUT" ,
10491062 )
1050- print ("Reference dataset uploaded!" )
1063+ if self .verbose :
1064+ print ("Reference dataset uploaded!" )
10511065
10521066 def upload_reference_dataframe (
10531067 self ,
@@ -1111,7 +1125,8 @@ def stream_data(
11111125 body = body ,
11121126 include_metadata = False ,
11131127 )
1114- print ("Stream published!" )
1128+ if self .verbose :
1129+ print ("Stream published!" )
11151130
11161131 def _strip_read_only_fields (self , config : Dict [str , any ]) -> Dict [str , any ]:
11171132 """Strips read-only fields from the config."""
@@ -1187,7 +1202,8 @@ def publish_batch_data(
11871202 ),
11881203 presigned_url_query_params = presigned_url_query_params ,
11891204 )
1190- print ("Data published!" )
1205+ if self .verbose :
1206+ print ("Data published!" )
11911207
11921208 def _validate_production_data_and_load_config (
11931209 self ,
@@ -1316,4 +1332,5 @@ def publish_ground_truths(
13161332 presigned_url_endpoint = f"inference-pipelines/{ inference_pipeline_id } /presigned-url" ,
13171333 presigned_url_query_params = presigned_url_query_params ,
13181334 )
1319- print ("Ground truths published!" )
1335+ if self .verbose :
1336+ print ("Ground truths published!" )
0 commit comments