Skip to content

[FEATURE]: extract line number in metrics declaration #1725

@shahzebsiddiqui

Description

@shahzebsiddiqui

Please describe your feature

Buildtest should have ability to extract line from stdout/stderr that can be assigned to a metric which can be used later for status check. For instance let's take the following results from OSU bandwidth test result and we want to extract a particular line

# OSU MPI Bandwidth Test v7.3                                                                                                                                                                                                                                              
# Size      Bandwidth (MB/s)                                                                                                                                                                                                                                               
# Datatype: MPI_CHAR.                                                                                                                                                                                                                                                      
1                       5.65                                                                                                                                                                                                                                               
2                       3.57                                                                                                                                                                                                                                               
4                       9.26                                                                                                                                                                                                                                               
8                      33.72                                                                                                                                                                                                                                               
16                     20.76                                                                                                                                                                                                                                               
32                    161.53                                                                                                                                                                                                                                               
64                    133.98                                                                                                                                                                                                                                               
128                   705.10                                                                                                                                                                                                                                               
256                   534.20                                                                                                                                                                                                                                               
512                   708.01                                                                                                                                                                                                                                               
1024                  390.97                                                                                                                                                                                                                                               
2048                  899.16                                                                                                                                                                                                                                               
4096                 5240.26                                                                                                                                                                                                                                               
8192                 3275.13                                                                                                                                                                                                                                               
16384                4527.77                                                                                                                                                                                                                                               
32768                6407.88                                                                                                                                                                                                                                               
65536                9635.86                                                                                                                                                                                                                                               
131072              15361.67                                                                                                                                                                                                                                               
262144              10873.81                                                                                                                                                                                                                                               
524288              18213.85                                                                                                                                                                                                                                               
1048576             10275.43                                                                                                                                                                                                                                               
2097152             11507.50                                                                                                                                                                                                                                               
4194304              4837.92     

At the moment we have support for regex in metrics that can be used as comparison which works fine.

buildspecs:
  osu_bandwidth_perf:
    type: script
    executor: generic.local.bash
    description: Run OSU Bandwidth Performance Test
    run:  mpirun -np 2 osu_bw
    metrics:
      osu_bw:
        type: float
        regex:
          exp: '^16384\s+([\d.]+)$'
          stream: stdout
          item: 1
    status:
      assert_ge:
        comparisons:
          - name: osu_bw
            ref: 10000

This regex is applied on entire content of file and not on a particular line.

For this feature, we would like to add a key something like linenum that will be used to extract a particular line where regex is applied. To extend this example we can simply do the following

buildspecs:
  osu_bandwidth_perf:
    type: script
    executor: generic.local.bash
    description: Run OSU Bandwidth Performance Test
    run:  mpirun -np 2 osu_bw
    metrics:
      osu_bw:
        type: float
        regex:
          exp: '^16384\s+([\d.]+)$'
          stream: stdout
          linenum: 10
          item: 1
    status:
      assert_ge:
        comparisons:
          - name: osu_bw
            ref: 10000

The linenum must be an integer and it can be any value including negative values. The idea is that we simply extract the line from file and apply regex on the specific line. linenum: -1 would mean last line of file and linenum: 0 would be first line of file.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions