feat: add reports and model management helpers#22
Conversation
Signed-off-by: dingdayu <614422099@qq.com>
Signed-off-by: dingdayu <614422099@qq.com>
Signed-off-by: dingdayu <614422099@qq.com>
There was a problem hiding this comment.
💡 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".
| SetContext(ctx). | ||
| SetHeader("Accept", AcceptJSONError). | ||
| SetResult(&resp). | ||
| Get(fmt.Sprintf("/reports/reports/%s", url.PathEscape(reportID))) |
There was a problem hiding this comment.
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 👍 / 👎.
| SelectionType: defaultString(opts.SelectionType, "perSection"), | ||
| SectionIndex: opts.SectionIndex, | ||
| Size: defaultString(opts.Size, "800x600"), | ||
| RenderLimit: defaultPositive(opts.RenderLimit, 1), |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
💡 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".
| SetHeader("Accept-Language", "en"). | ||
| SetContentType(AcceptMLProject). | ||
| SetQueryParam("action", "retrainProject"). | ||
| SetBody(resp). |
There was a problem hiding this comment.
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 👍 / 👎.
| for name, value := range inputData { | ||
| inputs = append(inputs, ScoreInput{Name: name, Value: value}) |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
💡 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".
| ModifiedBy string `json:"modifiedBy,omitempty"` | ||
| ModifiedTimeStamp time.Time `json:"modifiedTimeStamp,omitempty"` | ||
| Version int `json:"version,omitempty"` | ||
| Links []Link `json:"links,omitempty"` |
There was a problem hiding this comment.
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 👍 / 👎.
Signed-off-by: dingdayu <614422099@qq.com>
There was a problem hiding this comment.
💡 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".
| defer span.End() | ||
|
|
||
| req := reportImageJobRequest{ | ||
| ReportURI: fmt.Sprintf("/reports/reports/%s", reportID), |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
💡 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".
|
|
||
| req := reportImageJobRequest{ | ||
| ReportURI: fmt.Sprintf("/reports/reports/%s", url.PathEscape(reportID)), | ||
| LayoutType: defaultString(opts.LayoutType, "thumbnail"), |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
💡 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".
| SetContext(ctx). | ||
| SetHeader("Accept", AcceptJSONError). | ||
| SetResult(&definition). | ||
| Get(fmt.Sprintf("/reports/%s/content", url.PathEscape(reportID))) |
There was a problem hiding this comment.
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>
|
@codex pls Review all. |
There was a problem hiding this comment.
💡 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".
| ModifiedBy string `json:"modifiedBy,omitempty"` | ||
| ModifiedTimeStamp time.Time `json:"modifiedTimeStamp,omitempty"` | ||
| Version int `json:"version,omitempty"` | ||
| Images []ReportImage |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
💡 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".
| if opts.LayoutType != "" { | ||
| return opts.LayoutType | ||
| } | ||
| if opts.SectionIndex != 0 { |
There was a problem hiding this comment.
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>
|
Warning Review limit reached
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 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. 📝 WalkthroughWalkthroughThis 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. ChangesReports and Model Management APIs
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (7)
README.mdexamples/viya-cli/todo.mdmodels.gomodels_test.goreports.goreports_test.goresponse.go
Signed-off-by: dingdayu <614422099@qq.com>
|
@codex pls review |
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Verification
Summary by CodeRabbit
New Features
Documentation