Progress

class Progress[source]

Bases: object

Modules operations monitoring and displaying statistics of data processing. Progress object is immutable.

Parameters
message : str

Progress message e.g. “Images uploaded:”, “Processing:”.

total_cnt : int, optional

Total count.

ext_logger : logger, optional

Logger object.

is_size : bool, optional

Shows Label size.

need_info_log : bool, optional

Shows info log.

min_report_percent : int, optional

Minimum report percent of total items in progress to log.

Usage example
import supervisely as sly
from supervisely.sly_logger import logger

address = 'https://app.supervise.ly/'
token = 'Your Supervisely API Token'
api = sly.Api(address, token)

progress = sly.Progress("Images downloaded: ", len(img_infos), ext_logger=logger, is_size=True, need_info_log=True)
api.image.download_paths(ds_id, image_ids, save_paths, progress_cb=progress.iters_done_report)

# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Images downloaded: ", "current": 0,
#  "total": 6, "current_label": "0.0 B", "total_label": "6.0 B", "timestamp": "2021-03-17T13:57:45.659Z", "level": "info"}
# {"message": "Images downloaded:  [0.0 B / 6.0 B]", "timestamp": "2021-03-17T13:57:45.660Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Images downloaded: ", "current": 1,
#  "total": 6, "current_label": "1.0 B", "total_label": "6.0 B", "timestamp": "2021-03-17T13:57:46.134Z", "level": "info"}
# {"message": "Images downloaded:  [1.0 B / 6.0 B]", "timestamp": "2021-03-17T13:57:46.134Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Images downloaded: ", "current": 2,
#  "total": 6, "current_label": "2.0 B", "total_label": "6.0 B", "timestamp": "2021-03-17T13:57:46.135Z", "level": "info"}
# {"message": "Images downloaded:  [2.0 B / 6.0 B]", "timestamp": "2021-03-17T13:57:46.135Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Images downloaded: ", "current": 3,
#  "total": 6, "current_label": "3.0 B", "total_label": "6.0 B", "timestamp": "2021-03-17T13:57:46.135Z", "level": "info"}
# {"message": "Images downloaded:  [3.0 B / 6.0 B]", "timestamp": "2021-03-17T13:57:46.135Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Images downloaded: ", "current": 4,
#  "total": 6, "current_label": "4.0 B", "total_label": "6.0 B", "timestamp": "2021-03-17T13:57:46.135Z", "level": "info"}
# {"message": "Images downloaded:  [4.0 B / 6.0 B]", "timestamp": "2021-03-17T13:57:46.135Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Images downloaded: ", "current": 5,
#  "total": 6, "current_label": "5.0 B", "total_label": "6.0 B", "timestamp": "2021-03-17T13:57:46.136Z", "level": "info"}
# {"message": "Images downloaded:  [5.0 B / 6.0 B]", "timestamp": "2021-03-17T13:57:46.136Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Images downloaded: ", "current": 6,
#  "total": 6, "current_label": "6.0 B", "total_label": "6.0 B", "timestamp": "2021-03-17T13:57:46.136Z", "level": "info"}
# {"message": "Images downloaded:  [6.0 B / 6.0 B]", "timestamp": "2021-03-17T13:57:46.136Z", "level": "info"}

Methods

iter_done

Increments the current iteration counter by 1

iter_done_report

Increments the current iteration counter by 1 and logs a message depending on current number of iterations.

iters_done

Increments the current iteration counter by given count

iters_done_report

Increments the current iteration counter by given count and logs a message depending on current number of iterations.

need_report

rtype

bool

print_progress

Logs a message with level INFO on logger.

report_if_needed

Determines whether the message should be logged depending on current number of iterations

report_progress

Logs a message with level INFO in logger.

set

Sets counter current value and total value and logs a message depending on current number of iterations.

set_current_value

Increments the current iteration counter by this value minus the current value of the counter and logs a message depending on current number of iterations.

iter_done()[source]

Increments the current iteration counter by 1

Return type

None

iter_done_report()[source]

Increments the current iteration counter by 1 and logs a message depending on current number of iterations.

Returns

None

Return type

NoneType

Usage example
import supervisely as sly

progress = sly.Progress("Processing:", len(img_infos))
for img_info in img_infos:
    img_names.append(img_info.name)
    progress.iter_done_report()

# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 0, "total": 6, "timestamp": "2021-03-17T14:29:33.207Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 1, "total": 6, "timestamp": "2021-03-17T14:29:33.207Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 2, "total": 6, "timestamp": "2021-03-17T14:29:33.207Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 3, "total": 6, "timestamp": "2021-03-17T14:29:33.207Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 4, "total": 6, "timestamp": "2021-03-17T14:29:33.207Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 5, "total": 6, "timestamp": "2021-03-17T14:29:33.207Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 6, "total": 6, "timestamp": "2021-03-17T14:29:33.207Z", "level": "info"}
iters_done(count)[source]

Increments the current iteration counter by given count

Parameters
count : int

Amount of iters

Return type

None

iters_done_report(count)[source]

Increments the current iteration counter by given count and logs a message depending on current number of iterations.

Parameters
count : int

Counter.

Returns

None

Return type

NoneType

Usage example
import supervisely as sly

progress = sly.Progress("Processing:", len(img_infos))
for img_info in img_infos:
    img_names.append(img_info.name)
    progress.iters_done_report(1)

# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 0, "total": 6, "timestamp": "2021-03-17T14:31:21.655Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 1, "total": 6, "timestamp": "2021-03-17T14:31:21.655Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 2, "total": 6, "timestamp": "2021-03-17T14:31:21.655Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 3, "total": 6, "timestamp": "2021-03-17T14:31:21.655Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 4, "total": 6, "timestamp": "2021-03-17T14:31:21.655Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 5, "total": 6, "timestamp": "2021-03-17T14:31:21.655Z", "level": "info"}
# {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Processing:",
#  "current": 6, "total": 6, "timestamp": "2021-03-17T14:31:21.655Z", "level": "info"}
print_progress()[source]

Logs a message with level INFO on logger. Message contain type of progress, subtask message, currtnt and total number of iterations

Return type

None

report_if_needed()[source]

Determines whether the message should be logged depending on current number of iterations

Return type

None

report_progress()[source]

Logs a message with level INFO in logger. Message contain type of progress, subtask message, current and total number of iterations

Returns

None

Return type

NoneType

set(current, total, report=True)[source]

Sets counter current value and total value and logs a message depending on current number of iterations.

Parameters
current : int

Current count.

total : int, optional

Total count.

report : bool

Defines whether to report to log or not.

Returns

None

Return type

NoneType

set_current_value(value, report=True)[source]

Increments the current iteration counter by this value minus the current value of the counter and logs a message depending on current number of iterations.

Parameters
value : int

Current value.

report : bool

Defines whether to report to log or not.

Returns

None

Return type

NoneType