Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Negate the deprecated offline flag in CometLogger - #21921

Open
VenishPaneliya wants to merge 2 commits into
Lightning-AI:masterfrom
VenishPaneliya:comet-offline-flag
Open

Negate the deprecated offline flag in CometLogger#21921
VenishPaneliya wants to merge 2 commits into
Lightning-AI:masterfrom
VenishPaneliya:comet-offline-flag

Conversation

@VenishPaneliya

Copy link
Copy Markdown

The compatibility shim for the deprecated offline kwarg assigns it straight onto online:

# handle old "offline" experiment flag
if "offline" in kwargs:
    log.warning("The parameter `offline is deprecated, please use `online` instead.")
    if online is None:
        online = kwargs.pop("offline")

offline and online are opposites, so the flag is inverted. online flows to self._online and then to comet_ml.start(online=self._online):

CometLogger(offline=True)   ->  comet_ml.start(online=True)     # expected False
CometLogger(offline=False)  ->  comet_ml.start(online=False)    # expected True

CometLogger(offline=True) therefore starts a fully online experiment and uploads the run, which is the opposite of what the caller asked for. Before online was introduced in #20275 the code was self.mode = "offline" if offline else "online", so the inversion is exactly what the shim is meant to preserve.

The two neighbouring shims in the same block map synonyms — project_name onto project, save_dir onto offline_directory — where a direct assignment is right. This one maps antonyms, which is easy to miss.

Only callers still passing the deprecated offline kwarg are affected; anyone on online is unchanged.

Added test_comet_logger_deprecated_offline_flag, which checks both directions. It fails on master and passes here; tests/tests_pytorch/loggers/test_comet.py goes 8 -> 9 passing.

One thing worth flagging for reviewers: there is a separate bug just below at the disabled=True block (#21617, being fixed in #21619 / #21634). Until that lands, this change moves offline=True from "silently uploads online" to "silently disabled" rather than to a working offline experiment. That is still strictly better — no unintended upload — but the two want to land together to give offline=True its intended behaviour.

The compatibility shim maps the old `offline` kwarg onto `online`
without inverting it:

    if online is None:
        online = kwargs.pop("offline")

`offline` and `online` are opposites, so `CometLogger(offline=True)`
starts an online experiment and uploads the run, and `offline=False`
starts an offline one. Before the `online` parameter was introduced the
code read `self.mode = "offline" if offline else "online"`, so the
inversion is what the shim is meant to preserve.

The two neighbouring shims map synonyms - `project_name` onto `project`,
`save_dir` onto `offline_directory` - which is why a direct assignment
looks right here but is not.

Only callers still passing the deprecated `offline` kwarg are affected;
`online` is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant