Skip to content

Confusing behavior of Context.from_options and statistics #1065

@TomAugspurger

Description

@TomAugspurger

After #1009, calling Context.from_options with an Options enabling statistics doesn't result in a Context with enabled statistics.

import rapidsmpf.config
import rapidsmpf.statistics
import rapidsmpf.streaming.core.context
import rapidsmpf.communicator.single
import rapidsmpf.progress_thread
import rapidsmpf.rmm_resource_adaptor
import rmm


# confusing behavior: Context.from_options() doesn't honor statistics=True in Options;

opts = rapidsmpf.config.Options({"statistics": "True"})

comm = rapidsmpf.communicator.single.new_communicator(
    progress_thread=rapidsmpf.progress_thread.ProgressThread(),
    options=opts,
)
mr = rapidsmpf.rmm_resource_adaptor.RmmResourceAdaptor(rmm.mr.get_current_device_resource())

context = rapidsmpf.streaming.core.context.Context.from_options(
    comm.logger,
    mr,
    opts
)
assert context.statistics().enabled  # AssertionError

you need to instead pass in a Statistics, likely built from Statistics.from_options(opts):

context = rapidsmpf.streaming.core.context.Context.from_options(
    comm.logger,
    mr,
    opts,
    rapidsmpf.statistics.Statistics.from_options(opts)

)
assert context.statistics().enabled  # True

Having two ways to specify the statistics is confusing. I'd recommend one or the other: rapidsmpf should consistently use the options anywhere a statistics might be created / used, or it should not have a statistics option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions