Skip to content

Conversation

@edsavage
Copy link
Contributor

@edsavage edsavage commented Sep 4, 2020

Refactor foreground persistence to allow for using supplied descriptors when snapshotting model state.
This paves the way for upgrading model state.

Refactor foreground persistence to allow for using supplied descriptors when snapshotting model state.
This paves the way for upgrading model state.

core_t::TTime snapshotTimestamp(core::CTimeUtils::now());
const std::string snapshotId(core::CStringUtils::typeToString(snapshotTimestamp));
const std::string description{"Periodic background persist at " + snapshotId};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const std::string description{"Periodic background persist at " + snapshotId};
const std::string description{"Periodic background persist at " + core::CTimeUtils::toIso8601(snapshotTimestamp)};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


// Compare snapshot ID embedded in the state string with the supplied value.
const std::string expectedId{"job_model_state_" +
std::to_string(snapshotTimestamp) + "#1"};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::to_string(snapshotTimestamp) + "#1"};
snapshotId + "#1"};

It's just coincidence that the snapshot ID is the snapshot timestamp in this case. The document ID is supposed to include the snapshot ID regardless of whether it's the same as the snapshot timestamp.

job.finalise();

ml::core_t::TTime snapshotTimestamp{1283524206};
const std::string snapshotId{ml::core::CStringUtils::typeToString(snapshotTimestamp)};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably best to set the snapshot ID to something different to the snapshot timestamp, just to prove that the code being tested doesn't mix up the snapshot ID and the snapshot timestamp.

Suggested change
const std::string snapshotId{ml::core::CStringUtils::typeToString(snapshotTimestamp)};
const std::string snapshotId{"my_special_snapshot"};

std::string& snapshotIdOut,
std::size_t& numDocsOut) {
LOG_DEBUG(<< "Persist complete with description: " << modelSnapshotReport.s_Description);
description = modelSnapshotReport.s_Description;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also capture the snapshot timestamp so tests can assert that is as expected too.

// Check that the snapshot description and Id reported by the "persist complete"
// handler match those supplied to the persist function
BOOST_REQUIRE_EQUAL(description, description_);
BOOST_REQUIRE_EQUAL(snapshotId, snapshotId_);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also assert that the snapshot timestamp is as expected.

Copy link

@droberts195 droberts195 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@droberts195
Copy link

The CI failed because of the change of Gradle task name in the ES repo. To get it to work you need to merge latest master into the PR branch.

@edsavage edsavage merged commit c3eebc9 into elastic:master Sep 7, 2020
edsavage added a commit to edsavage/ml-cpp that referenced this pull request Sep 7, 2020
Refactor foreground persistence to allow for using supplied descriptors when snapshotting model state.
This paves the way for upgrading model state.
edsavage added a commit that referenced this pull request Sep 7, 2020
Refactor foreground persistence to allow for using supplied descriptors when snapshotting model state.
This paves the way for upgrading model state.

Backports #1473
@edsavage edsavage deleted the refactor_persistence_code branch September 7, 2020 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants