Skip to content

feat: add reports and model management helpers#22

Merged
dingdayu merged 12 commits into
mainfrom
feat/models_and_reports
Jun 9, 2026
Merged

feat: add reports and model management helpers#22
dingdayu merged 12 commits into
mainfrom
feat/models_and_reports

Conversation

@dingdayu

@dingdayu dingdayu commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add Visual Analytics report helpers for listing reports, getting report metadata/definition, and creating report image jobs
  • Add Model Management helpers for AutoML projects, registered models, MAS modules, and MAS scoring
  • Document the new root-package support in the README and update the viya-cli TODO

Verification

  • gofmt -w .
  • go test ./...

Summary by CodeRabbit

  • New Features

    • Added report management: list Visual Analytics reports, retrieve report definitions, and create report image rendering jobs.
    • Added model management: list and create AutoML projects, run project retraining, list registered models and published scoring modules, and score data with module steps.
  • Documentation

    • Updated README with Reports and Model Management supported features.
    • Updated capability tracking documentation.

dingdayu added 3 commits June 3, 2026 13:57
Signed-off-by: dingdayu <614422099@qq.com>
Signed-off-by: dingdayu <614422099@qq.com>
Signed-off-by: dingdayu <614422099@qq.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ae87f67f7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread reports.go
SetContext(ctx).
SetHeader("Accept", AcceptJSONError).
SetResult(&resp).
Get(fmt.Sprintf("/reports/reports/%s", url.PathEscape(reportID)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fetch report content from the content endpoint

For callers using GetReport as documented to retrieve both metadata and the report definition, this only calls /reports/reports/{id}; the SAS Reports API returns the report resource metadata there, while the BIRD report definition/content is exposed separately at /reports/{reportId}/content. As a result, real reports will come back without the definition payload even though the README and test name advertise it.

Useful? React with 👍 / 👎.

Comment thread reports.go Outdated
SelectionType: defaultString(opts.SelectionType, "perSection"),
SectionIndex: opts.SectionIndex,
Size: defaultString(opts.Size, "800x600"),
RenderLimit: defaultPositive(opts.RenderLimit, 1),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow no-limit report image renders

When a caller wants all per-section images, the reportImages API uses renderLimit=-1 for no limit and defaults to no limit, but this clamps every non-positive value to 1. That means multi-section reports render only the first image by default, and callers cannot request the documented no-limit behavior because passing RenderLimit: -1 is overwritten here.

Useful? React with 👍 / 👎.

Signed-off-by: dingdayu <614422099@qq.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54f9d99f42

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread models.go Outdated
SetHeader("Accept-Language", "en").
SetContentType(AcceptMLProject).
SetQueryParam("action", "retrainProject").
SetBody(resp).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the full project when retraining

For real retrains, this PUT body is only the reduced MLProject metadata decoded by the preceding GET, so fields such as dataTableUri, settings, and analyticsProjectAttributes are dropped even though the SAS retrainProject request body requires the project details. The test fixture returns only id/name, but a real service can reject this incomplete body or retrain with missing parameters; use a full project representation or preserve the raw GET payload for the PUT.

Useful? React with 👍 / 👎.

Comment thread models.go Outdated
Comment on lines +128 to +129
for name, value := range inputData {
inputs = append(inputs, ScoreInput{Name: name, Value: value})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid randomizing MAS step input order

For MAS steps with multiple inputs, building the request from a Go map makes the inputs slice order nondeterministic, while MAS step execution expects input values to be in the step signature order. Callers using this helper can therefore intermittently send values in the wrong positions and see validation or scoring failures; prefer an ordered []ScoreInput helper or derive the order from step metadata.

Useful? React with 👍 / 👎.

Signed-off-by: dingdayu <614422099@qq.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3513cf344c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread reports.go
ModifiedBy string `json:"modifiedBy,omitempty"`
ModifiedTimeStamp time.Time `json:"modifiedTimeStamp,omitempty"`
Version int `json:"version,omitempty"`
Links []Link `json:"links,omitempty"`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve report image result links

For report-image jobs that finish immediately or return partial results, the reportImages response carries the actual SVG retrieval links under an images array; this struct only keeps the job-level self/state links, so Resty silently drops the per-image links and callers have no way to fetch the rendered section images from GetReportImage. Add an Images field with the image metadata/links to the decoded response.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

清检查这个是否已修复 @codex

Signed-off-by: dingdayu <614422099@qq.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28a123ea88

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread reports.go Outdated
defer span.End()

req := reportImageJobRequest{
ReportURI: fmt.Sprintf("/reports/reports/%s", reportID),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Escape report IDs in image job URIs

When reportID contains URI-reserved characters such as spaces or slashes, this embeds the raw value into the reportUri request body instead of escaping it like GetReport does for path segments. In those cases the reportImages service receives an invalid or different report URI (for example a slash splits the ID into extra path segments), so callers can create jobs that fail to render the intended report; build this URI with url.PathEscape(reportID).

Useful? React with 👍 / 👎.

Signed-off-by: dingdayu <614422099@qq.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 24b3e2bbde

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread reports.go Outdated

req := reportImageJobRequest{
ReportURI: fmt.Sprintf("/reports/reports/%s", url.PathEscape(reportID)),
LayoutType: defaultString(opts.LayoutType, "thumbnail"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor SectionIndex for section image jobs

When callers pass only ReportImageOptions{SectionIndex: n}, the request still defaults to layoutType: "thumbnail"; the SAS reportImages create-job docs state that sectionIndex applies only when layoutType==entireSection (https://developer.sas.com/rest-apis/reportImages-v2/createJob). In real Viya this means the section choice is ignored and the helper can render the default thumbnail/per-section output instead of the requested report page, so the default should switch to an entire-section layout when using SectionIndex or otherwise expose/document a way that actually makes the field effective.

Useful? React with 👍 / 👎.

Signed-off-by: dingdayu <614422099@qq.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a585e91f7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread reports.go Outdated
SetContext(ctx).
SetHeader("Accept", AcceptJSONError).
SetResult(&definition).
Get(fmt.Sprintf("/reports/%s/content", url.PathEscape(reportID)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the report content resource path

For real report IDs, this second GET omits the report collection segment: the Reports service exposes report resources at /reports/reports/{id} and its content link at /reports/reports/{id}/content (also shown in the updateContent links returned with reports), while this requests /reports/{id}/content. As a result, GetReport can successfully fetch metadata and then fail with 404 before returning the definition payload.

Useful? React with 👍 / 👎.

Signed-off-by: dingdayu <614422099@qq.com>
@dingdayu

dingdayu commented Jun 5, 2026

Copy link
Copy Markdown
Owner Author

@codex pls Review all.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c59b9c8971

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread reports.go Outdated
ModifiedBy string `json:"modifiedBy,omitempty"`
ModifiedTimeStamp time.Time `json:"modifiedTimeStamp,omitempty"`
Version int `json:"version,omitempty"`
Images []ReportImage

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add the missing JSON tag for images

When callers re-encode a returned ReportImageJob (for example for CLI JSON output or logging API responses), this field currently marshals as "Images" instead of the SAS-style "images" used by the service and by the rest of this package's response structs. That makes the public response type produce inconsistent JSON for consumers even though unmarshalling from the service happens to work case-insensitively.

Useful? React with 👍 / 👎.

Signed-off-by: dingdayu <614422099@qq.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ff8484bd9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread reports.go Outdated
if opts.LayoutType != "" {
return opts.LayoutType
}
if opts.SectionIndex != 0 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Render the first section for zero SectionIndex

This still treats SectionIndex == 0 as “not supplied”, but report sections are zero-based and the reportImages API only applies sectionIndex when layoutType is entireSection. In the common case where a caller requests the first page with ReportImageOptions{SectionIndex: 0}, this falls through to the thumbnail default and the section choice is ignored; fresh evidence is the new opts.SectionIndex != 0 guard, which only fixes nonzero sections.

Useful? React with 👍 / 👎.

Signed-off-by: dingdayu <614422099@qq.com>
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@dingdayu, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 52 minutes and 13 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8a177f4e-79a5-40c8-933d-42f0dc8a4e16

📥 Commits

Reviewing files that changed from the base of the PR and between 235b59e and 79f3ddb.

📒 Files selected for processing (1)
  • reports.go
📝 Walkthrough

Walkthrough

This PR extends the SAS Viya Go client library with two new feature areas: Visual Analytics reports management and AutoML/MAS model management. It adds data models, typed client methods with OpenTelemetry instrumentation, comprehensive HTTP integration tests, media-type constants, and documentation updates across eight new/modified files totaling 1,116 lines.

Changes

Reports and Model Management APIs

Layer / File(s) Summary
Media type constants
response.go
Exports three new REST API media-type constants for report image jobs and AutoML projects.
Reports API: data models, client methods, and tests
reports.go, reports_test.go
Defines Report, ReportImageOptions, ReportImageJob, ReportImage types and response aliases; implements GetReports, GetReport, GetReportImage client methods with tracing, validation, and error handling; includes helpers for defaulting layout type, section index, and render limit; validates HTTP requests, response parsing, ID escaping, header negotiation, and edge cases via eight test functions.
Models and ML API: data models, client methods, and tests
models.go, models_test.go
Defines AutoML project, settings, analytics attributes, registered model, MAS module, and scoring request types with helper constructors; implements GetMLProjects, CreateMLProject, RunMLProject, GetRegisteredModels, GetModelsAndDecisions, ScoreData client methods with tracing, validation, ETag-based conditional updates, and error handling; validates required fields, request body shapes, collection queries, retrain sequencing (GET then PUT), input order preservation, and parameter validation via ten test functions.
Documentation updates
README.md, examples/viya-cli/todo.md
Extends "Supported Features" with new Reports and Model Management sections; updates todo list to document implementation via reports.go and models.go.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 A rabbit hops through reports and models fine,
Scoring data, AutoML designs align,
With tracing spans and tests so bright,
The Viya client now shines with light! 🌟

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the main objectives and includes testing verification steps, but does not follow the required template structure with explicit Testing and Compatibility sections and checkboxes. Restructure the description to match the template with Testing section containing the checkbox items and a Compatibility section confirming no exported APIs were removed/renamed and behavior is documented.
Docstring Coverage ⚠️ Warning Docstring coverage is 7.69% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main changes: adding report and model management helper functions. It accurately reflects the primary features introduced in the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/models_and_reports

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@reports.go`:
- Line 129: The code assigns resp["definition"] = definition which can panic if
resp is nil; before that assignment in reports.go ensure resp is initialized
(e.g., if resp == nil { resp = make(map[string]interface{}) } or otherwise
allocate the map) so the map exists before injecting the "definition" key;
locate the resp variable and the assignment to "definition" and add a
nil-check/initialization immediately prior to the assignment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 53d109e2-3afd-4fdd-bae4-6796164a21f9

📥 Commits

Reviewing files that changed from the base of the PR and between 0cd869b and 235b59e.

📒 Files selected for processing (7)
  • README.md
  • examples/viya-cli/todo.md
  • models.go
  • models_test.go
  • reports.go
  • reports_test.go
  • response.go

Comment thread reports.go
Signed-off-by: dingdayu <614422099@qq.com>
@dingdayu

dingdayu commented Jun 5, 2026

Copy link
Copy Markdown
Owner Author

@codex pls review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dingdayu dingdayu merged commit df5010c into main Jun 9, 2026
4 checks passed
@dingdayu dingdayu deleted the feat/models_and_reports branch June 9, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant