@@ -38,7 +38,10 @@ def __repr__(self):
3838
3939 def __enter__ (self ):
4040 if self ._create_callback is None :
41- raise RuntimeError ('It can not be used to create context' )
41+ raise ValueError ("The job is already created and can't be used to create context."
42+ " To be able to use context: create job without 'query_str' parameter: "
43+ "\n >>> with con.jobs.create('j1') as job:"
44+ "\n >>> job.add_query(...)" )
4245 set_saving (f'job-{ self .name } ' )
4346
4447 return self
@@ -47,7 +50,7 @@ def __exit__(self, type, value, traceback):
4750 set_saving (None )
4851 if type is None :
4952 if len (self ._queries ) == 0 :
50- raise RuntimeError ('No queries were added to job' )
53+ raise ValueError ('No queries were added to job' )
5154
5255 query_str = '; ' .join (self ._queries )
5356
@@ -79,7 +82,7 @@ def add_query(self, query: Union[Query, str]):
7982
8083 query = query .sql
8184 elif not isinstance (query , str ):
82- raise RuntimeError (f'Unable to use add this object as a query: { query } . Try to use sql string instead' )
85+ raise ValueError (f'Unable to use add this object as a query: { query } . Try to use sql string instead' )
8386 self ._queries .append (query )
8487
8588 def get_history (self ) -> pd .DataFrame :
@@ -164,7 +167,7 @@ def create(
164167 Usage options:
165168
166169 Option 1: to use string query
167- All job tasks could be passed as string with sql queries. Job is created emmideiately
170+ All job tasks could be passed as string with sql queries. Job is created immediately
168171
169172 >>> job = con.jobs.create('j1', query_str='retrain m1; show models', repeat_min=1):
170173
0 commit comments