Skip to content

Started work on the #902, .lower function call and "None" checking added - #904

Closed
alexermolovich wants to merge 1 commit into
petercorke:mainfrom
alexermolovich:backend-registry-issue-902
Closed

alexermolovich wants to merge 1 commit into
petercorke:mainfrom
alexermolovich:backend-registry-issue-902

Conversation

@alexermolovich

Copy link
Copy Markdown

Thanks for contributing to RTB!

Summary

Related issue

Checklist

Only the first item below is checked automatically — the rest are a self-check for you before requesting review, nothing currently verifies them for you.

  • I checked that no other open PR already addresses this Issue, and commented on the Issue to claim it
  • PR title follows Conventional Commits (type: description) — checked automatically, see the "Check PR title" status
  • Tests pass locally (pytest)
  • Added/updated tests for this change, if applicable
  • New/changed code is type-hinted with modern syntax (X | Y, list[X], not Union/Optional/List)
  • Docstrings updated (reST style: :param:, :returns:; type hints in the signature cover types now, :type:/:rtype: are rarely needed)
  • PR is as small/focused as practical — if it tackles several unrelated things, consider splitting it so each can be reviewed and accepted independently
  • I understand that the Codacy check is advisory (it reports assert in tests as "high" security), only All tests passed and the PR title check are required — see CONTRIBUTING
  • If this change alters numerical results or public behaviour, I have said so in the summary above, even if it is a bug fix
  • If an AI assistant wrote or helped with this change, I have said so in the summary above, and I have read the diff myself
  • No test files, data files, or notebooks specific to your own project — PyPI has strict package size limits, and RTB is already split into a toolbox and a data package. Notebooks, if of general interest, should have output cleared before committing.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

petercorke added a commit that referenced this pull request Nov 18, 2026
* feat(backends): a registry of backends by name

load_backend() was an if/elif over three names.  The names are now entries in
a registry, and register_backend() adds more: a lazy "module:Class" string, which
is imported only when the backend is chosen, or a callable that returns one.
Names are not case sensitive.  An unknown name lists the registered ones, and a
missing package names the pip extra.  This is groundwork for #886, so a backend
can be developed and used outside the Toolbox.

Part of #902.  No change to what the built-in backends do.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* refactor(robot): backend names are not case sensitive, and are plain strings

robot.default_backend = "Swift" was kept as given and failed with ValueError at
plot time.  The name is now normalised where it is set (default_backend and
set_default_backend) and where it is given (plot and teach), by one function in
the registry.  A name that is not a string is a TypeError where it is set.

The backend argument of plot() and teach() was Literal["swift", "pyplot",
"pyplot2"], which would reject a registered backend; it is now str, checked at
runtime against the registry.

Part of #902.  Supersedes the lower-casing in #904.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* refactor(robot): plot() asks a backend what it can do, not what class it is

plot() recognised Swift by type(env).__name__ == "Swift" and PyPlot by
isinstance, so a new backend could not be a web page shown in a notebook, or
make a movie, without being named or derived like one of them.  Two flags on
Connector, both False by default, replace the checks:

- embeds_in_notebook: the backend is a web page that can be shown in the cell
  of a notebook (set by Swift), which plot() asks for in a notebook, and
  paces an animation in real time
- supports_movie: the backend has getframe() (set by PyPlot)

They are read with getattr, as supports_teach and supports_ellipse are, so a
backend that does not inherit from Connector, as Swift does not, need not
define them.  Behaviour of the built-in backends is unchanged.

Part of #902.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* docs(backends): document the backend registry and the capability flags

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
@petercorke

Copy link
Copy Markdown
Owner

Thank you, Alex, for starting this. Your PR pointed at exactly the right place: the backend name handling in BaseRobot. The registry that came out of Issue #902 has now merged (PR #953), and it includes the case-insensitive backend names that your .lower() change started, along with a check that the name is a string. So I am closing this as superseded, with thanks. Your Isaac Sim work in PR #907 is the next user of the registry, and I have left comments there.

@petercorke petercorke closed this Nov 18, 2026
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.

2 participants