Skip to content

Commit 7c58f62

Browse files
lu-wang-dlxuanwang14
authored andcommitted
[ML-8575] Extend stack CLI to support html format (#263)
* add html support for stack cli * clean up
1 parent cc72ea7 commit 7c58f62

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

databricks_cli/workspace/types.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class WorkspaceLanguage(object):
3030
SQL = 'SQL'
3131
R = 'R'
3232
ALL = [SCALA, PYTHON, SQL, R]
33-
EXTENSIONS = ['.scala', '.py', '.sql', '.SQL', '.r', '.R', '.ipynb']
33+
EXTENSIONS = ['.scala', '.py', '.sql', '.SQL', '.r', '.R', '.ipynb', '.html']
3434

3535
@classmethod
3636
def to_language_and_format(cls, path):
@@ -45,6 +45,8 @@ def to_language_and_format(cls, path):
4545
return (cls.R, WorkspaceFormat.SOURCE)
4646
elif ext == '.ipynb':
4747
return (cls.PYTHON, WorkspaceFormat.JUPYTER)
48+
elif ext == '.html':
49+
return (None, WorkspaceFormat.HTML)
4850

4951
@classmethod
5052
def to_extension(cls, language):

tests/stack/test_api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,13 @@ def test_deploy_workspace(self, stack_api, tmpdir):
301301
assert nb_databricks_id == {api.WORKSPACE_RESOURCE_PATH:
302302
test_workspace_nb_properties[api.WORKSPACE_RESOURCE_PATH]}
303303

304+
# Test Input of Workspace notebook with html source
305+
test_workspace_nb_properties.update(
306+
{api.WORKSPACE_RESOURCE_SOURCE_PATH: 'test/notebook.html'})
307+
nb_databricks_id = \
308+
stack_api._deploy_workspace(test_workspace_nb_properties, None, True)
309+
assert stack_api.workspace_client.import_workspace.call_args[0][0] == 'test/notebook.html'
310+
304311
# Should raise error if resource object_type doesn't match actually is in filesystem.
305312
test_workspace_dir_properties.update(
306313
{api.WORKSPACE_RESOURCE_OBJECT_TYPE: workspace_api.NOTEBOOK})

0 commit comments

Comments
 (0)