client

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteProject

func ExecuteProject(ctx context.Context, cfg *Config, name, instructions string, bag rubrics.RunBag, items ...rubrics.Evaluator) error

ExecuteProject executes a grading workflow using the provided evaluators. The name parameter identifies the project/assignment being graded. The instructions parameter is used for AI quality evaluation when QualityClient is configured. If bag is nil, a new empty bag is created. Otherwise, the provided bag is used (for pre-configured context). If ProgramBuilder is nil, defaults to creating a Program with the provided Env. This function is generic and can be used by any course-specific implementation.

func PromptForSubmission

func PromptForSubmission(ctx context.Context, w io.Writer, r io.Reader) bool

PromptForSubmission asks the user if they want to submit results to the server. Returns true if user confirms, false otherwise. The caller must pass a non-nil writer and reader; this function will not default them. If either the writer or reader is nil, the function will log a warning and return false. Accepts "y", "Y", "yes", "YES" (case-insensitive, whitespace-trimmed).

Types

type AuthTransport

type AuthTransport struct {
	// contains filtered or unexported fields
}

AuthTransport injects an Authorization header for every outgoing request. It wraps an existing http.RoundTripper and adds a "Authorization: Bearer {token}" header to each outgoing request.

func NewAuthTransport

func NewAuthTransport(token string, base http.RoundTripper) *AuthTransport

NewAuthTransport creates a new AuthTransport with the given token. If base is nil, defaultTLSTransport() is used.

func (*AuthTransport) RoundTrip

func (t *AuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper by adding an Authorization header to each request.

type Config

type Config struct {
	ServerURL string

	// ClientVersion is the version of the running CLI.
	ClientVersion string

	// Execution specific fields
	WorkDir WorkDir
	RunCmd  string
	Env     map[string]string

	// Connect client for the QualityService
	QualityClient protoconnect.QualityServiceClient

	// Connect client for the RubricService
	RubricClient protoconnect.RubricServiceClient

	// Writer is where the resulting rubric table will be written. If nil, defaults to os.Stdout
	Writer io.Writer

	// Reader is where to read user input from. If nil, defaults to os.Stdin
	Reader io.Reader

	// ProgramBuilder creates a ProgramRunner for a given working directory and run command.
	// If nil, defaults to creating a Program with ExecCommandBuilder using Env.
	// This is the primary extension point for testing and customization.
	ProgramBuilder func(workDir, runCmd string) (rubrics.ProgramRunner, error)
}

Config represents configuration for the grading client

func (*Config) UploadResult

func (cfg *Config) UploadResult(ctx context.Context, result *rubrics.Result) error

UploadResult prompts the user for confirmation and uploads the rubric result to the server. If RubricClient is nil, logs and returns without error. If Reader is nil, defaults to os.Stdin for user input.

type DirectoryError

type DirectoryError struct {
	Err error
	// contains filtered or unexported fields
}

DirectoryError represents an error related to directory access

func (*DirectoryError) Error

func (e *DirectoryError) Error() string

func (*DirectoryError) Unwrap

func (e *DirectoryError) Unwrap() error

type WorkDir

type WorkDir string

WorkDir is a validated project directory path

func (WorkDir) String

func (w WorkDir) String() string

String returns the string representation of WorkDir

func (WorkDir) Validate

func (w WorkDir) Validate() error

Validate implements Kong's Validatable interface for WorkDir validation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL