MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / RunMetadata

Class RunMetadata

tensorflow/core/summary/summary_db_writer.cc:384–621  ·  view source on GitHub ↗

\brief Run metadata manager. This class gives us Tag IDs we can pass to SeriesWriter. In order to do that, rows are created in the Ids, Tags, Runs, Experiments, and Users tables. This class is thread safe.

Source from the content-addressed store, hash-verified

382///
383/// This class is thread safe.
384class RunMetadata {
385 public:
386 RunMetadata(IdAllocator* ids, const string& experiment_name,
387 const string& run_name, const string& user_name)
388 : ids_{ids},
389 experiment_name_{experiment_name},
390 run_name_{run_name},
391 user_name_{user_name} {
392 DCHECK(ids_ != nullptr);
393 }
394
395 const string& experiment_name() { return experiment_name_; }
396 const string& run_name() { return run_name_; }
397 const string& user_name() { return user_name_; }
398
399 int64 run_id() LOCKS_EXCLUDED(mu_) {
400 mutex_lock lock(mu_);
401 return run_id_;
402 }
403
404 Status SetGraph(Sqlite* db, uint64 now, double computed_time,
405 std::unique_ptr<GraphDef> g) SQLITE_TRANSACTIONS_EXCLUDED(*db)
406 LOCKS_EXCLUDED(mu_) {
407 int64 run_id;
408 {
409 mutex_lock lock(mu_);
410 TF_RETURN_IF_ERROR(InitializeRun(db, now, computed_time));
411 run_id = run_id_;
412 }
413 int64 graph_id;
414 SqliteTransaction txn(*db); // only to increase performance
415 TF_RETURN_IF_ERROR(
416 GraphWriter::Save(db, &txn, ids_, g.get(), now, run_id, &graph_id));
417 return txn.Commit();
418 }
419
420 Status GetTagId(Sqlite* db, uint64 now, double computed_time,
421 const string& tag_name, int64* tag_id,
422 const SummaryMetadata& metadata) LOCKS_EXCLUDED(mu_) {
423 mutex_lock lock(mu_);
424 TF_RETURN_IF_ERROR(InitializeRun(db, now, computed_time));
425 auto e = tag_ids_.find(tag_name);
426 if (e != tag_ids_.end()) {
427 *tag_id = e->second;
428 return Status::OK();
429 }
430 TF_RETURN_IF_ERROR(ids_->CreateNewId(tag_id));
431 tag_ids_[tag_name] = *tag_id;
432 TF_RETURN_IF_ERROR(
433 SetDescription(db, *tag_id, metadata.summary_description()));
434 const char* sql = R"sql(
435 INSERT INTO Tags (
436 run_id,
437 tag_id,
438 tag_name,
439 inserted_time,
440 display_name,
441 plugin_name,

Callers 1

RunMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected