buildtesters/buildtest

[FEATURE]: extract linenum from file_regex for metrics

shahzebsiddiqui opened this issue · 0 comments

Please describe your feature

This feature is similar to #1725 but for file_regex where we want to extract a line number from file instead of stdout/stderr.

Here is an example of metrics declaration for file_regex that will simply write one line to file.

buildspecs:
  metric_file_regex:
    executor: generic.local.bash
    type: script
    description: capture result metric from file path
    run: echo "HPCG result is VALID with a GFLOP/s rating of=63.6515" > hpcg.txt
    tags: tutorials
    metrics:
      hpcg_rating_file:
        type: float
        file_regex:
          exp: '(\d+\.\d+)$'
          file: hpcg.txt
      hpcg_state_file:
        type: str
        file_regex:
          exp: '(VALID)'
          file: hpcg.txt

We can add a field linenum that will extract the line from file and apply regex so we can do the following

  metric_file_regex:
    executor: generic.local.bash
    type: script
    description: capture result metric from file path
    run: echo "HPCG result is VALID with a GFLOP/s rating of=63.6515" > hpcg.txt
    tags: tutorials
    metrics:
      hpcg_rating_file:
        type: float
        file_regex:
          exp: '(\d+\.\d+)$'
          linenum: 0
          file: hpcg.txt
      hpcg_state_file:
        type: str
        file_regex:
          exp: '(VALID)'
          file: hpcg.txt

If there is an index error due to invalid line number the metrics would be undefined. This would be the default behavior of any metric if regex is not found then it will be not defined.

Suggest potential solution

No response

Additional Information

No response

Post question in Slack

  • I agree that I posted my question in slack before creating this issue

Is there an existing issue

  • I confirm there is no existing issue for this issue