Skip to content

Comments

Implementation of ID Code import functionality#226

Draft
sababak wants to merge 17 commits intomasterfrom
pr-EDMMMX-13662-id-python-code
Draft

Implementation of ID Code import functionality#226
sababak wants to merge 17 commits intomasterfrom
pr-EDMMMX-13662-id-python-code

Conversation

@sababak
Copy link
Collaborator

@sababak sababak commented Feb 5, 2026

Summary

This PR introduces Python code file functionality for SAS Intelligent Decisioning, it include ID code format validation, file import capabilities, and automated dependency detection.

New Features

Main methods

  • write_id_code_file() method: Uploads a python code file to Viya file service, optionally validate code formatting, create an ID Code file linked to uploaded file
  • validate_id_code() method: Validates Python code against SAS Intelligent Decisioning requirements

Code Validation System

  • validate_id_code() method: Validates Python code against SAS Intelligent Decisioning requirements
  • validate_code parameter: Optional boolean to disable validation (default: True)
  • Syntax validation: Automatic Python syntax checking
  • Structure validation: Ensures required execute function and proper docstrings

File Import Capabilities

  • Code support: Accepts pathlib.Path objects, file path strings, or code passed in as a string
  • Automatic file reading: Reads content from .py files when paths provided
  • Path resolution: Detects file paths vs. code strings
  • Error handling: Graceful handling of invalid paths

📋 Docstring Validation

  • Output validation: Ensures 'Output:' docstring matches return statements
  • Dependency validation: Validates 'DependentPackages:' docstring
  • Variable consistency: Matches output docstring variables with actual returns (ensures that docstring and all return statement all contain the same amount of variables)

🔍 Dependency Detection

  • Import analysis: Parses Python AST to detect imported packages
  • Standard library filtering: Excludes Python built-in modules
  • Package mapping: Handles import-to-install name conversions

Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
Signed-off-by: Samuel Babak <samuel.babak@sas.com>
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 96.25000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.53%. Comparing base (973fa82) to head (ea01611).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
src/sasctl/pzmm/code_file.py 97.22% 2 Missing ⚠️
src/sasctl/_services/files.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #226      +/-   ##
==========================================
+ Coverage   64.26%   64.53%   +0.26%     
==========================================
  Files          57       58       +1     
  Lines        6286     6339      +53     
==========================================
+ Hits         4040     4091      +51     
- Misses       2246     2248       +2     
Flag Coverage Δ
integration 64.53% <96.25%> (+0.26%) ⬆️
unit 64.53% <96.25%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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