Rename Task.reporter to Task._reporter (deprecated)

This commit is contained in:
allegroai 2020-09-01 17:47:40 +03:00
parent 99a8724bec
commit 4c77cd1479
5 changed files with 27 additions and 27 deletions

View File

@ -139,7 +139,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
self._input_model = None
self._output_model = None
self._metrics_manager = None
self._reporter = None
self.__reporter = None
self._curr_label_stats = {}
self._raise_on_validation_errors = raise_on_validation_errors
self._parameters_allowed_types = (
@ -511,14 +511,14 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
return self._get_metrics_manager(self.get_output_destination())
@property
def reporter(self):
def _reporter(self):
# type: () -> Reporter
"""
Returns a simple metrics reporter instance.
"""
if self._reporter is None:
if self.__reporter is None:
self._setup_reporter()
return self._reporter
return self.__reporter
def _get_metrics_manager(self, storage_uri):
# type: (str) -> Metrics
@ -538,8 +538,8 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
storage_uri = self.get_output_destination(log_on_error=False)
except ValueError:
storage_uri = None
self._reporter = Reporter(self._get_metrics_manager(storage_uri=storage_uri))
return self._reporter
self.__reporter = Reporter(self._get_metrics_manager(storage_uri=storage_uri))
return self.__reporter
def _get_output_destination_suffix(self, extra_path=None):
# type: (Optional[str]) -> str

View File

@ -703,7 +703,7 @@ class Artifacts(object):
# send for upload
# noinspection PyProtectedMember
self._task.reporter._report(ev)
self._task._reporter._report(ev)
return uri

View File

@ -384,7 +384,7 @@ class PatchedMatplotlib:
_pylab_helpers.Gcf.set_active(stored_figure)
# get the main task
reporter = PatchedMatplotlib._current_task.reporter
reporter = PatchedMatplotlib._current_task._reporter
if reporter is not None:
if mpl_fig.texts:
plot_title = mpl_fig.texts[0].get_text()

View File

@ -142,7 +142,7 @@ class Logger(object):
# if task was not started, we have to start it
self._start_task_if_needed()
self._touch_title_series(title, series)
return self._task.reporter.report_scalar(title=title, series=series, value=float(value), iter=iteration)
return self._task._reporter.report_scalar(title=title, series=series, value=float(value), iter=iteration)
def report_vector(
self,
@ -239,7 +239,7 @@ class Logger(object):
# if task was not started, we have to start it
self._start_task_if_needed()
self._touch_title_series(title, series)
return self._task.reporter.report_histogram(
return self._task._reporter.report_histogram(
title=title,
series=series,
histogram=values,
@ -322,7 +322,7 @@ class Logger(object):
replace("Inf", np.inf, math.inf)
replace("-Inf", -np.inf, np.NINF, -math.inf)
return self._task.reporter.report_table(
return self._task._reporter.report_table(
title=title,
series=series,
table=reporter_table,
@ -375,7 +375,7 @@ class Logger(object):
# if task was not started, we have to start it
self._start_task_if_needed()
self._touch_title_series(title, series[0].name if series else '')
return self._task.reporter.report_line_plot(
return self._task._reporter.report_line_plot(
title=title,
series=series,
iter=iteration,
@ -453,7 +453,7 @@ class Logger(object):
# if task was not started, we have to start it
self._start_task_if_needed()
self._touch_title_series(title, series)
return self._task.reporter.report_2d_scatter(
return self._task._reporter.report_2d_scatter(
title=title,
series=series,
data=scatter.astype(np.float32),
@ -547,7 +547,7 @@ class Logger(object):
# if task was not started, we have to start it
self._start_task_if_needed()
self._touch_title_series(title, series)
return self._task.reporter.report_3d_scatter(
return self._task._reporter.report_3d_scatter(
title=title,
series=series,
data=scatter,
@ -607,7 +607,7 @@ class Logger(object):
# if task was not started, we have to start it
self._start_task_if_needed()
self._touch_title_series(title, series)
return self._task.reporter.report_value_matrix(
return self._task._reporter.report_value_matrix(
title=title,
series=series,
data=matrix.astype(np.float32),
@ -707,7 +707,7 @@ class Logger(object):
# if task was not started, we have to start it
self._start_task_if_needed()
self._touch_title_series(title, series)
return self._task.reporter.report_value_surface(
return self._task._reporter.report_value_surface(
title=title,
series=series,
data=matrix.astype(np.float32),
@ -797,7 +797,7 @@ class Logger(object):
self._touch_title_series(title, series)
if url:
self._task.reporter.report_image(
self._task._reporter.report_image(
title=title,
series=series,
src=url,
@ -817,7 +817,7 @@ class Logger(object):
if isinstance(image, Image.Image):
image = np.array(image)
self._task.reporter.report_image_and_upload(
self._task._reporter.report_image_and_upload(
title=title,
series=series,
path=local_path,
@ -882,7 +882,7 @@ class Logger(object):
self._touch_title_series(title, series)
if url:
self._task.reporter.report_media(
self._task._reporter.report_media(
title=title,
series=series,
src=url,
@ -899,7 +899,7 @@ class Logger(object):
storage = StorageHelper.get(upload_uri)
upload_uri = storage.verify_upload(folder_uri=upload_uri)
self._task.reporter.report_media_and_upload(
self._task._reporter.report_media_and_upload(
title=title,
series=series,
path=local_path,
@ -939,7 +939,7 @@ class Logger(object):
plot['layout']['title'] = series
except Exception:
pass
self._task.reporter.report_plot(
self._task._reporter.report_plot(
title=title,
series=series,
plot=plot,
@ -1185,7 +1185,7 @@ class Logger(object):
storage = StorageHelper.get(upload_uri)
upload_uri = storage.verify_upload(folder_uri=upload_uri)
self._task.reporter.report_image_plot_and_upload(
self._task._reporter.report_image_plot_and_upload(
title=title,
series=series,
path=path,
@ -1237,7 +1237,7 @@ class Logger(object):
storage = StorageHelper.get(upload_uri)
upload_uri = storage.verify_upload(folder_uri=upload_uri)
self._task.reporter.report_image_and_upload(
self._task._reporter.report_image_and_upload(
title=title,
series=series,
path=path,

View File

@ -1154,7 +1154,7 @@ class Task(_Task):
# noinspection PyProtectedMember
self._logger._flush_stdout_handler()
if self._reporter:
self.reporter.flush()
self._reporter.flush()
LoggerRoot.flush()
return True
@ -2040,7 +2040,7 @@ class Task(_Task):
self._logger = Logger(private_task=self)
# make sure we set our reported to async mode
# we make sure we flush it in self._at_exit
self.reporter.async_enable = True
self._reporter.async_enable = True
# if we just created the logger, set default flush period
if not flush_period or flush_period is self.NotSet:
flush_period = DevWorker.report_period
@ -2394,7 +2394,7 @@ class Task(_Task):
# wait for uploads
print_done_waiting = False
if wait_for_uploads and (BackendModel.get_num_results() > 0 or
(self._reporter and self.reporter.get_num_results() > 0)):
(self._reporter and self._reporter.get_num_results() > 0)):
self.log.info('Waiting to finish uploads')
print_done_waiting = True
# from here, do not send log in background thread
@ -2402,7 +2402,7 @@ class Task(_Task):
self.flush(wait_for_uploads=True)
# wait until the reporter flush everything
if self._reporter:
self.reporter.stop()
self._reporter.stop()
if self.is_main_task():
# notice: this will close the reporting for all the Tasks in the system
Metrics.close_async_threads()