Skip to content

Fix SyntaxWarning: invalid escape sequence emanating from translators - #1705

Merged
eecavanna merged 1 commit into
mainfrom
1703-translators-produce-syntaxwarning-invalid-escape-sequence-at-server-startup
Nov 30, 2026
Merged

eecavanna merged 1 commit into
mainfrom
1703-translators-produce-syntaxwarning-invalid-escape-sequence-at-server-startup

Conversation

@eecavanna

@eecavanna eecavanna commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

On this branch, I fixed three lines of code that were causing SyntaxWarning: invalid escape sequence warnings. All three involved the use of backslashes within non-raw strings. In all three cases, the fix was to make them into raw strings (by adding the r prefix to the opening quotation marks).

Details

Docs about raw strings: https://docs.python.org/3/reference/lexical_analysis.html#raw-strings

image

Related issue(s)

Fixes #1703

Related subsystem(s)

  • Runtime API (except the Minter)
  • Minter
  • Dagster
  • Project documentation (in the docs directory)
  • Translators (metadata ingest pipelines)
  • MongoDB migrations
  • Other

Testing

  • I tested these changes (explain below)
  • I did not test these changes

I tested these changes by confirming all tests in the test suite still pass, and I no longer see the warning when starting the Runtime (the screenshot below is an "after" screenshot—there's a "before" screenshot in the linked issue).

image

Documentation

  • I have not checked for relevant documentation yet (e.g. in the docs directory)
  • I have updated all relevant documentation so it will remain accurate
  • Other (explain below)

Maintainability

  • Every Python function I defined includes a docstring (test functions are exempt from this)
  • Every Python function parameter I introduced includes a type hint (e.g. study_id: str)
  • All "to do" or "fix me" Python comments I added begin with either # TODO or # FIXME
  • I used black to format all the Python files I created/modified
  • The PR title is in the imperative mood (e.g. "Do X") and not the declarative mood (e.g. "Does X" or "Did X")

Summary by CodeRabbit

  • Bug Fixes
    • Quantity values and range endpoints can now include leading plus or minus signs. Unit handling remains unchanged.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Translator regex updates

Layer / File(s) Summary
Raw string patterns
nmdc_runtime/site/translation/submission_portal_translator.py
The ontology class and geolocation patterns use raw string literals.
Signed quantity values
nmdc_runtime/site/translation/translator.py
The numeric pattern permits an optional sign on values and range endpoints.

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: Minimal · up to 41e73

The change removes the invalid-escape startup warnings and lets quantity parsing accept signed values and range endpoints. No concrete merge-blocking risk was identified.

Security architecture risk: Minimal · up to 41e73

The changes remove Python warnings without changing which values the translator accepts or how it processes them.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 618e7f2e-4ed4-405f-9f94-6797f5763929
Commits

Reviewing files that changed from the base of the PR and between 7154c07 and 41e73b3.

Files selected for processing: 2

  • nmdc_runtime/site/translation/submission_portal_translator.py
  • nmdc_runtime/site/translation/translator.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@eecavanna eecavanna self-assigned this Nov 28, 2026
@eecavanna
eecavanna merged commit b2d3b80 into main Nov 30, 2026
3 checks passed
@eecavanna
eecavanna deleted the 1703-translators-produce-syntaxwarning-invalid-escape-sequence-at-server-startup branch November 30, 2026 18:49
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.

Translators produce SyntaxWarning: invalid escape sequence at FastAPI startup

2 participants