@@ -88,7 +88,7 @@ def deploy_cli(api_client, spec_arg, spec, allow_duplicate_names, pipeline_id):
8888 databricks pipelines deploy --pipeline-id 1234 --spec example.json
8989 """
9090 if bool (spec_arg ) == bool (spec ):
91- raise RuntimeError ('The spec should be provided either by an option or argument' )
91+ raise ValueError ('The spec should be provided either by an option or argument' )
9292 src = spec_arg if bool (spec_arg ) else spec
9393 spec_obj = _read_spec (src )
9494 if not pipeline_id and 'id' not in spec_obj :
@@ -254,7 +254,7 @@ def _read_spec(src):
254254 except json_parse_exception as e :
255255 error_and_quit ("Invalid JSON provided in spec\n {}" .format (e ))
256256 else :
257- raise RuntimeError ('The provided file extension for the spec is not supported' )
257+ raise ValueError ('The provided file extension for the spec is not supported' )
258258
259259
260260def _get_pipeline_url (api_client , pipeline_id ):
@@ -271,27 +271,11 @@ def _write_spec(src, spec):
271271 f .write (data )
272272
273273
274- def _get_pipeline_id (spec_arg , spec , pipeline_id ):
275- """
276- Ensures that the user has either specified a spec (either through argument or option) or a
277- pipeline ID directly, and returns the pipeline id to use.
278- """
279- # Only one out of spec/pipeline_id/spec_arg should be supplied
280- if bool (spec_arg ) + bool (spec ) + bool (pipeline_id ) != 1 :
281- raise RuntimeError ('Either spec should be provided as an argument '
282- 'or option, or the pipeline-id should be provided' )
283- if bool (spec_arg ) or bool (spec ):
284- src = spec_arg if bool (spec_arg ) else spec
285- pipeline_id = _read_spec (src )["id" ]
286- _validate_pipeline_id (pipeline_id )
287- return pipeline_id
288-
289-
290274def _validate_pipeline_id (pipeline_id ):
291275 """
292- Checks if the pipeline_id only contain -, _ and alphanumeric characters
276+ Checks if the pipeline_id is not empty and only contains -, _ and alphanumeric characters
293277 """
294- if len (pipeline_id ) == 0 :
278+ if pipeline_id is None or len (pipeline_id ) == 0 :
295279 error_and_quit (u'Empty pipeline id provided' )
296280 if not set (pipeline_id ) <= PIPELINE_ID_PERMITTED_CHARACTERS :
297281 message = u'Pipeline id {} has invalid character(s)\n ' .format (pipeline_id )
0 commit comments