Commit 06c79af3 authored by François Chabot's avatar François Chabot

Merge branch 'cfg_pass' into 'master'

better param passthrough

See merge request !126
parents 1facd033 67a91e90
Pipeline #96732649 failed with stages
in 10 minutes and 41 seconds
package orchestrator
const DOCKERFILE = `
FROM registry.gitlab.com/cogment/cogment/orchestrator:0.2.0-beta
FROM registry.gitlab.com/cogment/cogment/orchestrator:0.2.1-beta
ADD cogment.yaml .
`
......@@ -64,7 +64,10 @@ void Orchestrator::add_prehook(cogment::TrialHooks::Stub_interface* hook) {
*ctx.mutable_params() = default_trial_params_;
ctx.set_trial_id(to_string(new_trial->id()));
ctx.set_user_id(req.user_id());
if (req.has_config()) {
ctx.mutable_params()->mutable_trial_config()->set_content(
req.config().content());
}
prom.set_value(ctx);
}
......@@ -199,7 +202,6 @@ void Orchestrator::perform_trial_garbage_collection() {
std::unique_lock l(trials_mutex_);
auto trials = trials_;
l.unlock();
for (auto& trial : trials) {
if (trial.second->is_stale()) {
::cogment::TrialEndRequest req;
......
......@@ -47,17 +47,18 @@ Trial::~Trial() {
::easy_grpc::Future<void> Trial::configure(cogment::TrialParams cfg) {
auto trial_id = to_string(id_);
params_ = std::move(cfg);
// Launch the environment
env_stub_ = owner_->env_stubs_.get_stub(cfg.environment().endpoint());
env_stub_ = owner_->env_stubs_.get_stub(params_.environment().endpoint());
// Launch the environment, in parallell with the agent launches
std::vector<aom::Future<void>> agents_ready;
::cogment::EnvStartRequest env_start_req;
env_start_req.set_trial_id(trial_id);
if (cfg.environment().has_config()) {
*env_start_req.mutable_config() = cfg.environment().config();
if (params_.environment().has_config()) {
*env_start_req.mutable_config() = params_.environment().config();
}
// List of actors, organized per actor class
......@@ -66,7 +67,7 @@ Trial::~Trial() {
actor_counts_.resize(owner_->trial_spec_.actor_classes.size(), 0);
// Launch the actors, both AI and human
for (const auto& actor_info : cfg.actors()) {
for (const auto& actor_info : params_.actors()) {
auto class_id = owner_->trial_spec_.get_class_id(actor_info.actor_class());
auto url = actor_info.endpoint();
actor_counts_[class_id] += 1;
......@@ -325,9 +326,13 @@ void Trial::refresh_activity() {
}
bool Trial::is_stale() {
return params_.max_inactivity() > 0 &&
std::chrono::steady_clock::now() - last_activity_ >
std::chrono::seconds(params_.max_inactivity());
auto dt = std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::steady_clock::now() - last_activity_);
bool stale = std::chrono::steady_clock::now() - last_activity_ >
std::chrono::seconds(params_.max_inactivity());
spdlog::info("stale check: {} vs {}, {}", params_.max_inactivity(),
dt.count(), stale);
return params_.max_inactivity() > 0 && stale;
}
} // namespace aom
\ No newline at end of file
0.2.0-beta
\ No newline at end of file
0.2.1-beta
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment