Skip to content

Commit 9da4230

Browse files
committed
Added support for properties.json in jupyter plugin
1 parent aafb4da commit 9da4230

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

api/src/main/resources/plugins/jupyter.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def create_component(self, staged_component_path, application_name, user_name, c
7676
os.system('cp {}/jupyter_README.ipynb {}/README.ipynb'.format(this_dir, repo_path))
7777
os.system('cd {0} && git add README.ipynb && git commit -m "Initial commit"'.format(repo_path))
7878
## add notebooks to application_user github repo.
79-
notebook_install_path = '{}/{}/'.format(repo_path, application_name)
79+
notebook_install_path = '{}/{}'.format(repo_path, application_name)
8080
os.system('mkdir -p {}'.format(notebook_install_path))
8181
file_list = component['component_detail']
8282
for file_name in file_list:
@@ -86,7 +86,11 @@ def create_component(self, staged_component_path, application_name, user_name, c
8686
self._fill_properties('%s/%s' % (staged_component_path, file_name), properties)
8787
logging.debug('Copying {} to {}'.format(file_name, notebook_install_path))
8888
os.system('cp {}/{} {}'.format( staged_component_path, file_name, notebook_install_path ))
89-
# update local github repo:
89+
# Create a properties.json file in notebooks to access application jupyter component properties.
90+
with open('{}/properties.json'.format(notebook_install_path), 'w') as prop_file:
91+
prop_dict = { k.replace('component_',''): v for k, v in properties.items() if k.startswith('component_')}
92+
json.dump(prop_dict, prop_file)
93+
# update local github repo:
9094

9195
os.system('cd {0} && git add {1} && git commit -m "added {1} app notebooks"'.format(repo_path, application_name))
9296
delete_commands.append('rm -rf {}\n'.format( notebook_install_path))

0 commit comments

Comments
 (0)