Skip to content

logging improvements and version bump#79

Merged
parashardhapola merged 3 commits intomasterfrom
progress_bar_fixes
Apr 2, 2026
Merged

logging improvements and version bump#79
parashardhapola merged 3 commits intomasterfrom
progress_bar_fixes

Conversation

@parashardhapola
Copy link
Copy Markdown
Member

Version bump: 0.19.3 → 0.19.4

API URL migration: prod.cytetype.nygen.iocytetype.nygen.io (across main.py, README.md, and integration tests)

Progress display rewrite (cytetype/api/progress.py):

  • Replaced the per-cluster progress bar (individual cluster status with colored symbols) with a simpler single-line job-level status (queued / running / waiting)
  • Added Jupyter notebook support — detects ZMQInteractiveShell and uses an IPython DisplayHandle to update a single output cell in-place instead of printing repeated lines
  • Added elapsed time display (MM:SS) in interactive terminals
  • Spinner animation still updates in TTY mode; plain/non-TTY mode deduplicates repeated status lines
  • finalize() now accepts an explicit final_status string (completed, failed, timed_out) and only shows failed cluster details on failure
  • Constructor accepts an optional stream parameter for testability

Polling loop improvements (cytetype/api/client.py):

  • _sleep_with_spinner now receives job_status: str instead of the full cluster_status dict, matching the simplified progress display
  • New _log_report_cta() helper that logs the report URL prominently under a [TRACK PROGRESS] heading
  • Report URL is logged before the initial polling delay (so users see it immediately)
  • Log messages simplified: removed the job ID from the "submitted" message, rewrote the disconnect recovery hint
  • Report URL is also logged on failure and timeout paths

Post-annotation report link (cytetype/main.py):

  • After annotate() completes, the report URL is logged from adata.uns["{prefix}_jobDetails"]["report_url"]
  • Minor formatting fix in validate_adata call arguments

Tests:

  • New tests/test_api_client.py — unit tests for ProgressDisplay (plain output dedup, notebook display handle updates) and wait_for_completion (verifies report CTA is logged before polling begins)
  • tests/test_cytetype_integration.py — updated default API URL assertion
  • tests/test_validation.py — reformatted @pytest.mark.parametrize calls (style-only, no logic changes)

@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Progress display rewrite with notebook support and logging improvements

✨ Enhancement 🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Simplified progress display from per-cluster to job-level status
• Added Jupyter notebook support with in-place output updates
• Improved logging with prominent report URL tracking before polling
• Enhanced API URL migration and version bump to 0.19.4
• Added comprehensive unit tests for progress display and polling
Diagram
flowchart LR
  A["Job Submission"] --> B["Log Report URL"]
  B --> C["Start Polling"]
  C --> D["Update Progress Display"]
  D --> E{Display Mode}
  E -->|TTY| F["Spinner + Elapsed Time"]
  E -->|Notebook| G["Single Output Cell"]
  E -->|Plain| H["Deduplicated Lines"]
  F --> I["Job Completion"]
  G --> I
  H --> I
  I --> J["Finalize with Status"]
  J --> K["Show Failed Clusters if needed"]
Loading

Grey Divider

File Changes

1. cytetype/__init__.py ⚙️ Configuration changes +1/-1

Version bump to 0.19.4

• Version bumped from 0.19.3 to 0.19.4

cytetype/init.py


2. cytetype/api/progress.py ✨ Enhancement +138/-88

Complete rewrite of progress display system

• Replaced per-cluster progress bar with simplified job-level status display
• Added Jupyter notebook detection and in-place output cell updates via DisplayHandle
• Implemented elapsed time display (MM:SS format) for interactive terminals
• Added spinner animation for TTY mode and plain text deduplication for non-TTY
• Refactored finalize() to accept explicit final_status parameter and show failed clusters only
 on failure
• Added stream parameter to constructor for testability
• Simplified status messages and removed colored cluster symbols

cytetype/api/progress.py


3. cytetype/api/client.py ✨ Enhancement +27/-21

Polling loop improvements and report URL tracking

• Changed _sleep_with_spinner() to receive job_status: str instead of full cluster_status dict
• Added _log_report_cta() helper function to log report URL under [TRACK PROGRESS] heading
• Moved report URL logging before initial polling delay for immediate user visibility
• Simplified job submission log message and improved disconnect recovery hint
• Added report URL logging on failure and timeout paths
• Updated finalize() calls to pass explicit final_status parameter
• Initialize job_status and cluster_status variables at start of polling loop

cytetype/api/client.py


View more (5)
4. cytetype/main.py ✨ Enhancement +10/-3

API URL migration and post-annotation report logging

• Updated default API URL from prod.cytetype.nygen.io to cytetype.nygen.io
• Added report URL logging after annotate() completion from adata.uns metadata
• Reformatted validate_adata() call arguments for better readability

cytetype/main.py


5. tests/test_api_client.py 🧪 Tests +140/-0

New unit tests for progress display and polling

• New unit test file with comprehensive tests for ProgressDisplay and wait_for_completion
• Tests verify plain output deduplication avoids repeated status lines
• Tests verify notebook display handle updates single output cell instead of printing multiple lines
• Tests verify report CTA is logged before polling begins
• Includes helper classes for mocking logger, streams, and display handles

tests/test_api_client.py


6. tests/test_cytetype_integration.py 🧪 Tests +1/-1

Update API URL in integration test

• Updated default API URL assertion from prod.cytetype.nygen.io to cytetype.nygen.io

tests/test_cytetype_integration.py


7. tests/test_validation.py Formatting +63/-44

Reformat parametrize decorators for consistency

• Reformatted @pytest.mark.parametrize decorators for improved code style
• Expanded multi-line parameter lists with proper indentation
• No logic changes, style-only formatting updates

tests/test_validation.py


8. README.md 📝 Documentation +1/-1

Update example report URL

• Updated example report URL from prod.cytetype.nygen.io to cytetype.nygen.io

README.md


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Apr 2, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. TTY progress line artifacts🐞 Bug ⚙ Maintainability
Description
ProgressDisplay.update()/finalize() rewrite the current terminal line using '\r' but never clear the
remainder of the previous line, so when a shorter status replaces a longer one, leftover characters
remain visible. This produces confusing/garbled progress output in interactive TTY sessions
(cosmetic but user-facing).
Code

cytetype/api/progress.py[R65-68]

+        if self._interactive:
+            message = self._build_running_line(job_status)
+            print(f"\r{message}", end="", file=self.stream, flush=True)
+        elif self._use_notebook_display:
Evidence
Interactive rendering uses a carriage return to overwrite the current line but does not clear to
end-of-line. Since status strings have different lengths (e.g., “Waiting for CyteType job to
start...” vs “CyteType job running...”), switching from a longer to a shorter message will leave
trailing characters from the previous message on the screen; finalize() has the same pattern for the
last render.

cytetype/api/progress.py[60-74]
cytetype/api/progress.py[93-99]
cytetype/api/progress.py[133-142]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
In TTY mode, `ProgressDisplay` redraws the same line using `\r` but does not clear the rest of the line. When a shorter message replaces a longer one, trailing characters from the previous message remain visible.

### Issue Context
This affects interactive terminals (`stream.isatty() == True`). The status text varies in length depending on job state.

### Fix Focus Areas
- cytetype/api/progress.py[65-68]
- cytetype/api/progress.py[93-96]

### Suggested fix
When printing in interactive mode, append an ANSI clear-to-end-of-line sequence, e.g.:
- `print(f"\r{message}\033[K", end="", ...)` for `update()`
- `print(f"\r{message}\033[K", ...)` for `finalize()`

(Alternative: track the previous rendered length and right-pad with spaces.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@parashardhapola parashardhapola merged commit 7dbb3c5 into master Apr 2, 2026
1 check passed
@parashardhapola parashardhapola deleted the progress_bar_fixes branch April 2, 2026 03:12
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