Skip to content

Commit

Permalink
parameter callback renamed to callback_url, function _pass_callback r…
Browse files Browse the repository at this point in the history
…enamed to _pass_callback_url
  • Loading branch information
okolo committed Nov 28, 2023
1 parent 00a038d commit 64f026b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions nb2workflow/nbadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,13 @@ def update_summary(self, **d):



def execute(self, parameters, progress_bar = True, log_output = True, inplace=False, callback=None):
def execute(self, parameters, progress_bar = True, log_output = True, inplace=False, callback_url=None):
t0 = time.time()

logstasher.log(dict(origin="nb2workflow.execute", event="starting", parameters=parameters, workflow_name=notebook_short_name(self.notebook_fn), health=current_health()))

logger.info("starting job")
exceptions = self._execute(parameters, progress_bar, log_output, inplace, callback=callback)
exceptions = self._execute(parameters, progress_bar, log_output, inplace, callback_url=callback_url)

tspent = time.time() - t0
logstasher.log(dict(origin="nb2workflow.execute",
Expand All @@ -426,7 +426,7 @@ def execute(self, parameters, progress_bar = True, log_output = True, inplace=Fa

return exceptions

def _execute(self, parameters, progress_bar = True, log_output = True, inplace=False, callback=None):
def _execute(self, parameters, progress_bar = True, log_output = True, inplace=False, callback_url=None):

if not inplace :
tmpdir = self.new_tmpdir()
Expand All @@ -446,8 +446,8 @@ def _execute(self, parameters, progress_bar = True, log_output = True, inplace=F
tmpdir =os.path.dirname(os.path.realpath(self.notebook_fn))
logger.info("executing inplace, no tmpdir is input dir: %s", tmpdir)

if callback:
self._pass_callback(tmpdir, callback)
if callback_url:
self._pass_callback_url(tmpdir, callback_url)

self.update_summary(state="started", parameters=parameters)

Expand Down Expand Up @@ -490,15 +490,15 @@ def _execute(self, parameters, progress_bar = True, log_output = True, inplace=F

return exceptions

def _pass_callback(self, workdir: str, callback: str):
def _pass_callback_url(self, workdir: str, callback_url: str):
"""
save callback to file .oda_api_callback in the notebook dir were it can be accessed by ODA API
save callback_url to file .oda_api_callback in the notebook dir were it can be accessed by ODA API
:param notebook_path: full path to the notebook
"""
callback_file = ".oda_api_callback" # perhaps it would be better to define this constant in a common lib
callback_file_path = os.path.join(workdir, callback_file)
with open(callback_file_path, 'wt') as output:
print(callback, file=output)
print(callback_url, file=output)
logger.info("callback file created: %s", callback_file_path)

def extract_pm_output(self):
Expand Down

0 comments on commit 64f026b

Please sign in to comment.