Skip to content

Commit 5444cb8

Browse files
[SC-93969] Deprecate deploy in favor of create and edit and update CLI messages to reflect backend behavior (#437)
* Deprecate deploy in favor of create and edit. * update CLI messages to reflect backend behavior. Testing: - unittests - Manually running the commands and verifying Co-authored-by: Jonathan Seidman <[email protected]>
1 parent 1e852b5 commit 5444cb8

File tree

5 files changed

+466
-234
lines changed

5 files changed

+466
-234
lines changed

databricks_cli/click_types.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,13 @@ class SecretPrincipalClickType(ParamType):
9898

9999
class PipelineSpecClickType(ParamType):
100100
name = 'SPEC'
101-
help = 'The path to the pipelines deployment spec file.'
101+
help = '[Deprecated] Use the settings option instead. \n' + \
102+
'The path to the pipelines settings file.'
103+
104+
105+
class PipelineSettingClickType(ParamType):
106+
name = 'SETTINGS'
107+
help = 'The path to the pipelines settings file.'
102108

103109

104110
class PipelineIdClickType(ParamType):

databricks_cli/pipelines/api.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ def __init__(self, api_client):
4040
self.client = DeltaPipelinesService(api_client)
4141
self.dbfs_client = DbfsApi(api_client)
4242

43-
def create(self, spec, spec_dir, allow_duplicate_names, headers=None):
44-
data = self._upload_libraries_and_update_spec(spec, spec_dir)
43+
def create(self, settings, settings_dir, allow_duplicate_names, headers=None):
44+
data = self._upload_libraries_and_update_settings(settings, settings_dir)
4545
data['allow_duplicate_names'] = allow_duplicate_names
4646
return self.client.client.perform_query('POST', '/pipelines', data=data,
4747
headers=headers)
4848

49-
def deploy(self, spec, spec_dir, allow_duplicate_names, headers=None):
50-
data = self._upload_libraries_and_update_spec(spec, spec_dir)
49+
def edit(self, settings, settings_dir, allow_duplicate_names, headers=None):
50+
data = self._upload_libraries_and_update_settings(settings, settings_dir)
5151
data['allow_duplicate_names'] = allow_duplicate_names
5252
pipeline_id = data['id']
5353
self.client.client.perform_query('PUT', '/pipelines/{}'.format(pipeline_id), data=data,
@@ -86,14 +86,15 @@ def start_update(self, pipeline_id, full_refresh=None, headers=None):
8686
def stop(self, pipeline_id, headers=None):
8787
self.client.stop(pipeline_id, headers)
8888

89-
def _upload_libraries_and_update_spec(self, spec, spec_dir):
90-
spec = copy.deepcopy(spec)
91-
lib_objects = LibraryObject.from_json(spec.get('libraries', []))
89+
def _upload_libraries_and_update_settings(self, settings, settings_dir):
90+
settings = copy.deepcopy(settings)
91+
lib_objects = LibraryObject.from_json(settings.get('libraries', []))
9292
local_lib_objects, external_lib_objects = self._identify_local_libraries(lib_objects)
9393

94-
spec['libraries'] = LibraryObject.to_json(
95-
external_lib_objects + self._upload_local_libraries(spec_dir, local_lib_objects))
96-
return spec
94+
settings['libraries'] = LibraryObject.to_json(
95+
external_lib_objects + self._upload_local_libraries(
96+
settings_dir, local_lib_objects))
97+
return settings
9798

9899
@staticmethod
99100
def _identify_local_libraries(lib_objects):
@@ -124,9 +125,10 @@ def _identify_local_libraries(lib_objects):
124125
external_lib_objects.append(lib_object)
125126
return local_lib_objects, external_lib_objects
126127

127-
def _upload_local_libraries(self, spec_dir, local_lib_objects):
128-
relative_local_lib_objects = [LibraryObject(llo.lib_type, os.path.join(spec_dir, llo.path))
129-
for llo in local_lib_objects]
128+
def _upload_local_libraries(self, settings_dir, local_lib_objects):
129+
relative_local_lib_objects = [
130+
LibraryObject(
131+
llo.lib_type, os.path.join(settings_dir, llo.path)) for llo in local_lib_objects]
130132
remote_lib_objects = [LibraryObject(rllo.lib_type, self._get_hashed_path(rllo.path))
131133
for rllo in relative_local_lib_objects]
132134
transformed_remote_lib_objects = [LibraryObject(rlo.lib_type, DbfsPath(rlo.path))

0 commit comments

Comments
 (0)