Commit edceb282 authored by François Chabot's avatar François Chabot

Merge branch 'agent_config' into 'master'

Agent config

See merge request !142
parents a2119ec6 2d7115d4
Pipeline #110904443 passed with stages
in 10 minutes and 1 second
......@@ -5,7 +5,7 @@
#include "spdlog/spdlog.h"
namespace aom {
Agent::Agent(Trial* owner, stub_type stub, std::string config_data)
Agent::Agent(Trial* owner, stub_type stub, std::optional<std::string> config_data)
: Actor(to_string(owner->id()))
, owner_(owner)
, stub_(std::move(stub))
......@@ -21,7 +21,9 @@ namespace aom {
cogment::AgentStartRequest req;
req.set_trial_id(trial_id());
req.set_actor_id(actor_id());
req.mutable_config()->set_content(config_data_);
if(config_data_) {
req.mutable_config()->set_content(*config_data_);
}
for(auto i: owner_->actor_counts()) {
req.add_actor_counts(i);
......
......@@ -5,13 +5,15 @@
#include "aom/stub_pool.h"
#include "cogment/api/agent.egrpc.pb.h"
#include <optional>
namespace aom {
class Trial;
class Agent : public Actor {
public:
using stub_type = std::shared_ptr<aom::Stub_pool<cogment::Agent>::Entry>;
Agent(Trial* owner, stub_type stub, std::string config_data);
Agent(Trial* owner, stub_type stub, std::optional<std::string> config_data);
~Agent();
Future<void> init() override;
......@@ -30,7 +32,7 @@ private:
Trial* owner_;
stub_type stub_;
cogment::Action latest_action_;
std::string config_data_;
std::optional<std::string> config_data_;
};
} // namespace aom
......
......@@ -77,9 +77,12 @@ Trial::~Trial() {
human_actor->actor_class = &owner_->trial_spec_.actor_classes[class_id];
actors_per_class.at(class_id).push_back(std::move(human_actor));
} else {
std::optional<std::string> config;
if (actor_info.has_config()) {
config = actor_info.config().content();
}
auto stub_entry = owner_->agent_stubs_.get_stub(url);
auto actor = std::make_unique<Agent>(this, stub_entry,
actor_info.config().content());
auto actor = std::make_unique<Agent>(this, stub_entry, config);
actor->actor_class = &owner_->trial_spec_.actor_classes[class_id];
actors_per_class.at(class_id).push_back(std::move(actor));
}
......
0.2.2-beta
\ No newline at end of file
0.2.3-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