Skip to content

Commit

Permalink
rl_sim tenant id as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
peterychang committed Feb 6, 2024
1 parent 246697e commit 1a9212b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
9 changes: 5 additions & 4 deletions examples/rl_sim_cpp/azure_credentials.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

using namespace reinforcement_learning;

AzureCredentials::AzureCredentials(const std::string& tenant_id)
: _tenant_id(tenant_id),
_creds(create_options())
{}

Azure::Identity::AzureCliCredentialOptions AzureCredentials::create_options()
{
Azure::Identity::AzureCliCredentialOptions options;
Expand All @@ -22,10 +27,6 @@ Azure::Identity::AzureCliCredentialOptions AzureCredentials::create_options()
return options;
}

AzureCredentials::AzureCredentials()
: _creds(create_options())
{}

int AzureCredentials::get_credentials(const std::vector<std::string>& scopes,
std::string& token_out, std::chrono::system_clock::time_point& expiry_out)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/rl_sim_cpp/azure_credentials.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
class AzureCredentials
{
public:
AzureCredentials();
AzureCredentials(const std::string& tenant_id);
int get_credentials(const std::vector<std::string>& scopes,
std::string& token_out, std::chrono::system_clock::time_point& expiry_out);
private:
std::string _tenant_id;
#ifdef HAS_STD14
Azure::Identity::AzureCliCredentialOptions create_options();

//Azure::Identity::DefaultAzureCredential _creds;
Azure::Identity::AzureCliCredential _creds;
std::string _tenant_id = "<tenant_id>";
#endif
};
#endif
3 changes: 2 additions & 1 deletion examples/rl_sim_cpp/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ po::variables_map process_cmd_line(const int argc, char** argv)
"delay", po::value<int64_t>()->default_value(2000), "Delay between events in ms")(
"quiet", po::bool_switch(), "Suppress logs")("random_ids", po::value<bool>()->default_value(true),
"Use randomly generated Event IDs. Default is true")("throughput", "print throughput stats")(
"azure_oauth_factories", po::value<bool>()->default_value(false), "Use oauth for azure factores. Default false");
"azure_oauth_factories", po::value<bool>()->default_value(false), "Use oauth for azure factores. Default false")(
"azure_tenant_id", po::value<std::string>()->default_value(""), "Tenant ID for use with azure oauth factories.");

po::variables_map vm;
store(parse_command_line(argc, argv, desc), vm);
Expand Down
7 changes: 6 additions & 1 deletion examples/rl_sim_cpp/rl_sim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,12 @@ std::string rl_sim::create_event_id()
return oss.str();
}

rl_sim::rl_sim(boost::program_options::variables_map vm) : _options(std::move(vm)), _loop_kind(CB)
rl_sim::rl_sim(boost::program_options::variables_map vm)
: _options(std::move(vm))
, _loop_kind(CB)
#ifdef LINK_AZURE_LIBS
, _creds(_options["azure_tenant_id"].as<std::string>())
#endif
{
if (_options["ccb"].as<bool>()) { _loop_kind = CCB; }
else if (_options["slates"].as<bool>()) { _loop_kind = Slates; }
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
"name": "reinforcement-learning",
"version": "1.0.0",
"version": "1.0.1",
"builtin-baseline": "f30434939d5516ce764c549ab04e3d23d312180a",
"dependencies": [
"boost-align",
Expand Down

0 comments on commit 1a9212b

Please sign in to comment.