def test_missing_latest_job_results(): serializer = MagicMock() serializer.get_latest_job_id_for_name_and_params.return_value = None with patch("notebooker.utils.results._get_job_results") as get_results: result = results.get_latest_job_results(sentinel.report_name, sentinel.report_params, serializer, sentinel.retrying, sentinel.ignore_cache) get_results.assert_not_called() assert isinstance(result, constants.NotebookResultError) assert result.report_name == sentinel.report_name assert result.job_id is None assert result.overrides == sentinel.report_params
def latest_task_results_html(report_name): """This URL will ignore all paramterisation of the report and return the latest HTML output \ of any run for a given report name, regardless of its status. In this method, we either: - present the HTML results, if the job has finished - present the error, if the job has failed - present the user with some info detailing the progress of the job, if it is still running. :param report_name: The name of the template which we want to get the latest version of. :return: The HTML render of the absolute-latest run of a report, regardless of parametrization. """ return _process_result_or_abort(get_latest_job_results(report_name, None, get_serializer()))
def task_results_latest(report_name): """ Renders the full results page for a report_name. This searches the database for the last completed report for the given report_name. :param report_name: The name of the report :return: The HTML rendering of the results page for the latest successful execution of the given report_name. """ report_name = convert_report_name_url_to_path(report_name) params = _params_from_request_args(request.args) result = get_latest_job_results(report_name, params, get_serializer()) job_id = result.job_id return _render_results(job_id, report_name, result)
def latest_task_results_as_of(report_name, as_of): """This URL will ignore all paramterisation of the report and get the latest of any run for a given report name, \ Up to a given as_of date. In this method, we either: - present the HTML results, if the job has finished - present the error, if the job has failed - present the user with some info detailing the progress of the job, if it is still running. :param report_name: The name of the template which we want to get the latest version of, up to and including as_of. :param as_of: The maximum date of reports which we want to see. :return: The HTML render of the absolute-latest run of a report, regardless of parametrization. """ return _process_result_or_abort(get_latest_job_results(report_name, None, get_serializer(), as_of=as_of))
def task_latest_status(report_name): """ Searches for the latest status of the given report_name/override args combination, and returns the status with a redirect URL or stdout. :param report_name: The name of the report which we are searching for the latest status of. :return: A JSON which contains "status" and either stdout in "run_output" or a URL to results in "results_url". """ params = _params_from_request_args(request.args) result = get_latest_job_results(report_name, params, get_serializer()) job_id = result.job_id if job_id: return jsonify(_get_job_status(job_id, report_name)) return jsonify({"status": "Job not found for given overrides"})
def test_get_latest_job_results(): serializer = MagicMock() serializer.get_latest_job_id_for_name_and_params.return_value = sentinel.latest_job_id with patch("notebooker.utils.results._get_job_results", return_value=sentinel.result) as get_results: result = results.get_latest_job_results(sentinel.report_name, sentinel.report_params, serializer, sentinel.retrying, sentinel.ignore_cache) assert result == sentinel.result get_results.assert_called_once_with(sentinel.latest_job_id, sentinel.report_name, serializer, sentinel.retrying, sentinel.ignore_cache) serializer.get_latest_job_id_for_name_and_params.assert_called_once_with( sentinel.report_name, sentinel.report_params, None)
def latest_parameterised_task_results_html(report_name): """ Returns the HTML render of the .ipynb output of notebook execution. In the webapp this is rendered within an \ iframe. Searches the database for the last result as of the given date, regardless of status. \ Notebook parameters can be specified as request args, \ e.g. ?ticker=AAPL. In this method, we either: - present the HTML results, if the job has finished - present the error, if the job has failed - present the user with some info detailing the progress of the job, if it is still running. :param report_name: The name of the report :return: The HTML rendering of the .ipynb for the latest successful execution of the given report_name. """ params = _params_from_request_args(request.args) result = get_latest_job_results(report_name, params, get_serializer()) return _process_result_or_abort(result)