Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/custom counters #1513

Merged
merged 2 commits into from
Aug 2, 2021
Merged

Feature/custom counters #1513

merged 2 commits into from
Aug 2, 2021

Conversation

prekucki
Copy link
Member

@prekucki prekucki commented Jul 15, 2021

Example exe-unit configuration

[
  {
    "name": "gminer",
    "version": "0.1.0",
    "supervisor-path": "ya-runtime-gminer",
    "description": "Golem mining (PoC)",
    "extra-args": [],
    "config": {
      "counters": {
        "golem.usage.mining.hash": {
          "name": "share",
          "description": "Hash share normalized to 1GH",
          "price": true
        },
        "golem.usage.mining.share": {
          "name": "raw-share",
          "description": "Share count",
          "price": false
        },
        "golem.usage.duration_sec": {
          "name": "duration",
          "description": "Duration",
          "price": true
        }
      }
    }
  }
]

@prekucki prekucki requested review from mfranciszkiewicz and a team July 15, 2021 07:30
@nieznanysprawiciel nieznanysprawiciel linked an issue Jul 28, 2021 that may be closed by this pull request
Copy link
Contributor

@jiivan jiivan left a comment

Choose a reason for hiding this comment

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

I like most of changes you made, but I would like to ask you to focus more on the topic of the PR (Custom counters in this case). Doing so, helps a lot with planning (we might have a high priority for CC feature, but not so high for reformatting of 80+ files) & reviewing.

Please also remember about updating documentation (readme file and/or handbook) when changing CLI or golemsp

I would also like to ask you to revert changes that only reorder the use/import statements.

In this review I skipped the following parts:

  1. core/market
  2. core/vpn
  3. core/serv
  4. utils/transfer
  5. utils/networking
  6. goth_tests
  7. exe-unit

agent/provider/src/cli.rs Show resolved Hide resolved
agent/provider/src/cli/clean.rs Show resolved Hide resolved
let state = serde_json::to_value(globals_state)?;
let value = state
.get(&name)
.ok_or_else(|| anyhow::anyhow!("Invalid name global state property: {}", name))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.ok_or_else(|| anyhow::anyhow!("Invalid name global state property: {}", name))?;
.ok_or_else(|| anyhow::anyhow!("Config property not found: {}", name))?;

fn list(config: ProviderConfig) -> anyhow::Result<()> {
let registry = config.registry()?;
if let Err(errors) = registry.validate() {
log::error!("Encountered errors while checking ExeUnits:\n{}", errors);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
log::error!("Encountered errors while checking ExeUnits:\n{}", errors);
log::error!("Error encountered during ExeUnits registry validation. errors: {}", errors);

use structopt::StructOpt;

#[derive(StructOpt, Clone, Debug)]
pub enum ConfigConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub enum ConfigConfig {
pub enum GeneralConfig {

@@ -557,6 +560,7 @@ impl Handler<GetOfferTemplates> for TaskRunner {
log::info!("Reading offer template for {}", key);
let string = fut.await?;
let value = serde_json::from_str(string.as_str())?;
log::info!("offer-template: {} = {:?}", key, value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
log::info!("offer-template: {} = {:?}", key, value);
log::debug!("offer template: {} = {:?}", key, value);

@@ -383,9 +311,17 @@ where
}

fn default_plugins() -> PathBuf {
if let Some(mut exe) = env::current_exe().ok() {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to add this functionality, it should be documented in a provider documentation.

@@ -14,11 +15,11 @@ pub fn web_scope(db: &DbExecutor) -> Scope {
/// Common operations for both sides: Provider and Requestor
mod common {
use actix_web::{web, Responder};
use ya_service_bus::{timeout::IntoTimeoutFuture, RpcEndpoint};
Copy link
Contributor

Choose a reason for hiding this comment

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

It's the only change in this file. What is the benefit of this & how is it related to custom counters?

@@ -1,4 +1,5 @@
use std::time::Duration;

Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

.arg(format!("Init price={}", usage_coeffs.initial));
for &(k, v) in usage_coeffs {
cmd.arg("--price").arg(format!("{}={}", k, v));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@prekucki prekucki force-pushed the feature/custom-counters branch from 657fe8b to 0b1f396 Compare July 29, 2021 09:34
@prekucki prekucki requested a review from jiivan July 29, 2021 09:38
Copy link
Contributor

@jiivan jiivan left a comment

Choose a reason for hiding this comment

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

After clarification from @prekucki that, that this is mostly splitting previous code & after removing changes unrelated to provider - I approve.

For the next PRs I still kindly ask to avoid changes that reorganize whole use sequence only to add/remove one module or adding functionality unrelated to issue subject (vide plugins/ subdir).

@jiivan jiivan removed request for a team and mfranciszkiewicz August 2, 2021 13:38
@jiivan jiivan enabled auto-merge August 2, 2021 13:39
@jiivan jiivan merged commit dd4af35 into master Aug 2, 2021
@jiivan jiivan deleted the feature/custom-counters branch August 2, 2021 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom counter - Provider
2 participants