Skip to content

Commit

Permalink
Merge pull request #286 from ClusterCockpit/devel
Browse files Browse the repository at this point in the history
Sampling Feature for archived and fresh data
  • Loading branch information
spacehamster87 authored Aug 22, 2024
2 parents e74e506 + ceb3a09 commit 90886b6
Show file tree
Hide file tree
Showing 14 changed files with 358 additions and 95 deletions.
5 changes: 2 additions & 3 deletions internal/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ func cleanup() {
func TestRestApi(t *testing.T) {
restapi := setup(t)
t.Cleanup(cleanup)

testData := schema.JobData{
"load_one": map[schema.MetricScope]*schema.JobMetric{
schema.MetricScopeNode: {
Expand All @@ -189,7 +188,7 @@ func TestRestApi(t *testing.T) {
},
}

metricdata.TestLoadDataCallback = func(job *schema.Job, metrics []string, scopes []schema.MetricScope, ctx context.Context) (schema.JobData, error) {
metricdata.TestLoadDataCallback = func(job *schema.Job, metrics []string, scopes []schema.MetricScope, ctx context.Context, resolution int) (schema.JobData, error) {
return testData, nil
}

Expand Down Expand Up @@ -341,7 +340,7 @@ func TestRestApi(t *testing.T) {
}

t.Run("CheckArchive", func(t *testing.T) {
data, err := metricdata.LoadData(stoppedJob, []string{"load_one"}, []schema.MetricScope{schema.MetricScopeNode}, context.Background())
data, err := metricdata.LoadData(stoppedJob, []string{"load_one"}, []schema.MetricScope{schema.MetricScopeNode}, context.Background(), 60)
if err != nil {
t.Fatal(err)
}
Expand Down
18 changes: 16 additions & 2 deletions internal/api/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,15 @@ func (api *RestApi) getCompleteJobById(rw http.ResponseWriter, r *http.Request)

var data schema.JobData

metricConfigs := archive.GetCluster(job.Cluster).MetricConfig
resolution := 0

for _, mc := range metricConfigs {
resolution = max(resolution, mc.Timestep)
}

if r.URL.Query().Get("all-metrics") == "true" {
data, err = metricdata.LoadData(job, nil, scopes, r.Context())
data, err = metricdata.LoadData(job, nil, scopes, r.Context(), resolution)
if err != nil {
log.Warn("Error while loading job data")
return
Expand Down Expand Up @@ -604,7 +611,14 @@ func (api *RestApi) getJobById(rw http.ResponseWriter, r *http.Request) {
scopes = []schema.MetricScope{"node"}
}

data, err := metricdata.LoadData(job, metrics, scopes, r.Context())
metricConfigs := archive.GetCluster(job.Cluster).MetricConfig
resolution := 0

for _, mc := range metricConfigs {
resolution = max(resolution, mc.Timestep)
}

data, err := metricdata.LoadData(job, metrics, scopes, r.Context(), resolution)
if err != nil {
log.Warn("Error while loading job data")
return
Expand Down
2 changes: 1 addition & 1 deletion internal/graph/schema.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion internal/graph/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/99designs/gqlgen/graphql"
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
"github.com/ClusterCockpit/cc-backend/internal/metricdata"
"github.com/ClusterCockpit/cc-backend/pkg/archive"
"github.com/ClusterCockpit/cc-backend/pkg/log"
"github.com/ClusterCockpit/cc-backend/pkg/schema"
// "github.com/ClusterCockpit/cc-backend/pkg/archive"
Expand Down Expand Up @@ -47,7 +48,14 @@ func (r *queryResolver) rooflineHeatmap(
continue
}

jobdata, err := metricdata.LoadData(job, []string{"flops_any", "mem_bw"}, []schema.MetricScope{schema.MetricScopeNode}, ctx)
metricConfigs := archive.GetCluster(job.Cluster).MetricConfig
resolution := 0

for _, mc := range metricConfigs {
resolution = max(resolution, mc.Timestep)
}

jobdata, err := metricdata.LoadData(job, []string{"flops_any", "mem_bw"}, []schema.MetricScope{schema.MetricScopeNode}, ctx, resolution)
if err != nil {
log.Errorf("Error while loading roofline metrics for job %d", job.ID)
return nil, err
Expand Down
Loading

0 comments on commit 90886b6

Please sign in to comment.