-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wooda proof of concept; a bit polygon package refactor
- Loading branch information
Showing
8 changed files
with
319 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/Gornak40/algolymp/config" | ||
"github.com/Gornak40/algolymp/polygon" | ||
"github.com/Gornak40/algolymp/polygon/wooda" | ||
"github.com/akamensky/argparse" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func main() { | ||
cfg := config.NewConfig() | ||
woodaKeys := make([]string, 0, len(cfg.Polygon.Wooda)) | ||
for k := range cfg.Polygon.Wooda { | ||
woodaKeys = append(woodaKeys, k) | ||
} | ||
|
||
parser := argparse.NewParser("wooda", "Upload problem files filtered by regexp to Polygon.") | ||
pID := parser.Int("i", "pid", &argparse.Options{ | ||
Required: true, | ||
Help: "Polygon problem ID", | ||
}) | ||
mode := parser.Selector("m", "mode", woodaKeys, &argparse.Options{ | ||
Required: true, | ||
Help: "Local storage mode", | ||
}) | ||
pDir := parser.String("d", "directory", &argparse.Options{ | ||
Required: true, | ||
Help: "Local storage directory", | ||
}) | ||
if err := parser.Parse(os.Args); err != nil { | ||
logrus.WithError(err).Fatal("bad arguments") | ||
} | ||
|
||
pClient := polygon.NewPolygon(&cfg.Polygon) | ||
woodaCfg := cfg.Polygon.Wooda[*mode] // mode is good argparse.Selector | ||
wooda := wooda.NewWooda(pClient, *pID, &woodaCfg) | ||
if err := filepath.Walk(*pDir, wooda.DirWalker); err != nil { | ||
logrus.WithError(err).Fatal("failed wooda matching") | ||
} | ||
} | ||
|
||
/* | ||
"wooda": { | ||
"polygon": { | ||
"ignore": ["tests/*\.a"], | ||
"test": ["tests/*"], | ||
"validator": "files/val*\.cpp", | ||
"checker": "checker\.cpp", | ||
"solution": ["solutions/*\.cpp"], | ||
"generator": ["files/gen*\.cpp"] | ||
} | ||
} | ||
*/ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package polygon | ||
|
||
import "encoding/json" | ||
|
||
type TestAnswer struct { | ||
Index int `json:"index"` | ||
Group string `json:"group"` | ||
Points float32 `json:"points"` | ||
UseInStatements bool `json:"useInStatements"` | ||
} | ||
|
||
type GroupAnswer struct { | ||
Name string `json:"name"` | ||
PointsPolicy string `json:"pointsPolicy"` | ||
FeedbackPolicy string `json:"feedbackPolicy"` | ||
Dependencies []string `json:"dependencies"` | ||
} | ||
|
||
type Answer struct { | ||
Status string `json:"status"` | ||
Comment string `json:"comment"` | ||
Result json.RawMessage `json:"result"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package polygon | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
"strconv" | ||
) | ||
|
||
type TestRequest url.Values | ||
|
||
func NewTestRequest(pID int, index int) TestRequest { | ||
return TestRequest{ | ||
"problemId": []string{strconv.Itoa(pID)}, | ||
"testIndex": []string{strconv.Itoa(index)}, | ||
"testset": []string{defaultTestset}, | ||
} | ||
} | ||
|
||
func (tr TestRequest) Group(group string) TestRequest { | ||
tr["testGroup"] = []string{group} | ||
|
||
return tr | ||
} | ||
|
||
func (tr TestRequest) Points(points float32) TestRequest { | ||
tr["testPoints"] = []string{fmt.Sprint(points)} | ||
|
||
return tr | ||
} | ||
|
||
func (tr TestRequest) Input(input string) TestRequest { | ||
tr["testInput"] = []string{input} | ||
|
||
return tr | ||
} | ||
|
||
func (tr TestRequest) Description(description string) TestRequest { | ||
tr["testDescription"] = []string{description} | ||
|
||
return tr | ||
} |
Oops, something went wrong.