Skip to content

Commit

Permalink
internal/labels: switch config to YAML
Browse files Browse the repository at this point in the history
Switch to YAML from JSON so we can add comments and include
multiline text.

For #64.

Change-Id: Ibbfaf4ec66d8f7bc064d21257943166b26617770
Reviewed-on: https://go-review.googlesource.com/c/oscar/+/636715
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
jba committed Dec 16, 2024
1 parent 76e302b commit 0db0947
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 94 deletions.
14 changes: 7 additions & 7 deletions internal/devtools/cmd/labeleval/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Usage:
labeleval categoryconfig issueconfig
Categoryconfig defines the list of categories to use.
It is a JSON file that matches the type
It is a YAML file that matches the type
struct {
Categories []labels.Category
Expand All @@ -34,13 +34,12 @@ There are four results of evaluating an issue:
A typical run will use the category config from the internal/labels package and the list
of issues in this package. From repo root:
go run ./internal/devtools/cmd/labeleval internal/labels/static/categories.json internal/devtools/cmd/labeleval/issues.txt
go run ./internal/devtools/cmd/labeleval internal/labels/static/categories.yaml internal/devtools/cmd/labeleval/issues.txt
*/
package main

import (
"context"
"encoding/json"
"errors"
"flag"
"fmt"
Expand All @@ -61,6 +60,7 @@ import (
"golang.org/x/oscar/internal/secret"
"golang.org/x/oscar/internal/storage"
"golang.org/x/sync/errgroup"
"gopkg.in/yaml.v3"
)

var (
Expand Down Expand Up @@ -110,7 +110,7 @@ func run(ctx context.Context, categoryconfigFile, issueConfigFile string) error
Categories []labels.Category
}

if err := readJSONFile(categoryconfigFile, &categoryConfig); err != nil {
if err := readYAMLFile(categoryconfigFile, &categoryConfig); err != nil {
return err
}
knownCategories := map[string]bool{}
Expand Down Expand Up @@ -270,14 +270,14 @@ func newGeminiClient(ctx context.Context, lg *slog.Logger) (*gemini.Client, erro
return c, nil
}

func readJSONFile(filename string, p any) error {
func readYAMLFile(filename string, p any) error {
f, err := os.Open(filename)
if err != nil {
return err
}
defer f.Close()
dec := json.NewDecoder(f)
dec.DisallowUnknownFields()
dec := yaml.NewDecoder(f)
dec.KnownFields(true)
return dec.Decode(p)
}

Expand Down
8 changes: 5 additions & 3 deletions internal/labels/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"golang.org/x/oscar/internal/github"
"golang.org/x/oscar/internal/llm"
"gopkg.in/yaml.v3"
"rsc.io/markdown"
)

Expand Down Expand Up @@ -168,13 +169,14 @@ var config struct {
var staticFS embed.FS

func init() {
f, err := staticFS.Open("static/categories.json")
f, err := staticFS.Open("static/categories.yaml")
if err != nil {
log.Fatal(err)
}
defer f.Close()
dec := json.NewDecoder(f)
dec.DisallowUnknownFields()

dec := yaml.NewDecoder(f)
dec.KnownFields(true)
if err := dec.Decode(&config); err != nil {
log.Fatal(err)
}
Expand Down
84 changes: 0 additions & 84 deletions internal/labels/static/categories.json

This file was deleted.

56 changes: 56 additions & 0 deletions internal/labels/static/categories.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# File of categories used to classify GitHub issues.
# The category name is distinct from the name of the label used on the issue tracker.
# The description of a label should match the description on the issue tracker.
categories:
- name: bug
label: BUGLABEL
description: "Issues describing a bug in the Go implementation."
- name: languageProposal
label: LANGPROPLABEL
description: Issues describing a requested change to the Go language specification.
- name: libraryProposal
label: LIBPROPLABEL
description: Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool
- name: toolProposal
label: TOOLPROPLABEL
description: Issues describing a requested change to a Go tool or command-line program.
- name: implementation
label: IMPLABEL
description: Issues describing a semantics-preserving change to the Go implementation.
- name: accessRequest
label: accessRequestLABEL
description: Issues requesting builder or gomote access.
- name: pkgsiteRemovalRequest
label: pkgsite/package-removal
description: Issues for package removal. See https://pkg.go.dev/about#removing-a-package
# We don't label issues posted by gopherbot, so this label is probably unnecessary.
- name: automation
label: automationLABEL
description: Issues created by gopherbot or watchflakes automation.
- name: backport
label: backportLABEL
description: Issues created for requesting a backport of a change to a previous Go version.
- name: builders
label: Builders
description: x/build issues (builders, bots, dashboards)
- name: question
label: questionLABEL
description: Issues that are questions about using Go.
# It may be too challenging for the LLM to decide is something is WAI. Consider removing this.
- name: workingAsIntended
label: WorkingAsIntended
description: Issues describing something that is working as it is supposed to.
- name: featureRequest
label: FeatureRequestLABEL
description: Issues asking for a new feature that does not need a proposal.
- name: documentation
label: Documentation
description: Issues describing a change to documentation.
# The LLM never seems to pick invalid.
- name: invalid
label: invalidLABEL
description: Issues that are empty, incomplete, or spam.
# The LLM never seems to pick other.
- name: other
label: otherLABEL
description: None of the above.

0 comments on commit 0db0947

Please sign in to comment.