Skip to content

Commit b5b3350

Browse files
committed
refactor(commands): remove pre-1.6 embedding shims and dead tool config
The embed_single_item, embed_chunk and vectorize_source command handlers existed only so jobs queued by a pre-1.6 version could drain after an upgrade; any worker restarted on 1.6+ has no such jobs. Remove them, their input/output models and their tests. Also drop dead tooling config from pyproject.toml: the [tool.mypy] block (mypy.ini takes precedence and is the real config) and the Streamlit-era ruff per-file-ignores for app_home.py and pages/**, which no longer exist.
1 parent 5b253d7 commit b5b3350

4 files changed

Lines changed: 1 addition & 377 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
### Removed
1414
- Dead Streamlit-era service layer (~2,000 lines): `api/client.py` (a synchronous HTTP client that called the app's own API) and 13 `api/*_service.py` wrappers that consumed the app's own HTTP API — none were imported by any router, command or test. Also removed the toy `process_text`/`analyze_data` demo commands (`commands/example_commands.py`) from the background worker
15+
- Pre-1.6 embedding job compatibility shims (the `embed_single_item`, `embed_chunk` and `vectorize_source` command handlers) — they existed only so jobs queued by a pre-1.6 version could drain after an upgrade, and any worker restarted on 1.6+ has no such jobs. **Upgrade note:** if you are upgrading from a version older than 1.6 with embedding jobs still queued, drain the queue on a 1.x release before upgrading past this change. Also removed dead tooling config from `pyproject.toml`: the `[tool.mypy]` block (the real config is `mypy.ini`) and Streamlit-era ruff per-file-ignores for files that no longer exist
1516

1617
## [1.11.0] - 2026-07-11
1718

commands/embedding_commands.py

Lines changed: 0 additions & 264 deletions
Original file line numberDiff line numberDiff line change
@@ -118,58 +118,6 @@ class EmbedSourceOutput(CommandOutput):
118118
error_message: Optional[str] = None
119119

120120

121-
class LegacyEmbedSingleItemInput(CommandInput):
122-
"""Input for the pre-1.6 embed_single_item command kept for queued jobs."""
123-
124-
item_id: str
125-
item_type: Literal["source", "note", "insight"]
126-
127-
128-
class LegacyEmbedSingleItemOutput(CommandOutput):
129-
"""Output matching the pre-1.6 embed_single_item command shape."""
130-
131-
success: bool
132-
item_id: str
133-
item_type: str
134-
chunks_created: int = 0
135-
processing_time: float
136-
error_message: Optional[str] = None
137-
138-
139-
class LegacyEmbedChunkInput(CommandInput):
140-
"""Input for the pre-1.6 per-chunk embedding command kept for queued jobs."""
141-
142-
source_id: str
143-
chunk_index: int
144-
chunk_text: str
145-
146-
147-
class LegacyEmbedChunkOutput(CommandOutput):
148-
"""Output matching the pre-1.6 embed_chunk command shape."""
149-
150-
success: bool
151-
source_id: str
152-
chunk_index: int
153-
error_message: Optional[str] = None
154-
155-
156-
class LegacyVectorizeSourceInput(CommandInput):
157-
"""Input for the pre-1.6 vectorize_source command kept for queued jobs."""
158-
159-
source_id: str
160-
161-
162-
class LegacyVectorizeSourceOutput(CommandOutput):
163-
"""Output matching the pre-1.6 vectorize_source command shape."""
164-
165-
success: bool
166-
source_id: str
167-
total_chunks: int
168-
jobs_submitted: int
169-
processing_time: float
170-
error_message: Optional[str] = None
171-
172-
173121
@command(
174122
"embed_note",
175123
app="open_notebook",
@@ -501,218 +449,6 @@ async def embed_source_command(input_data: EmbedSourceInput) -> EmbedSourceOutpu
501449
raise
502450

503451

504-
@command(
505-
"embed_single_item",
506-
app="open_notebook",
507-
retry={
508-
"max_attempts": 5,
509-
"wait_strategy": "exponential_jitter",
510-
"wait_min": 1,
511-
"wait_max": 60,
512-
"stop_on": [ValueError, ConfigurationError],
513-
"retry_log_level": "debug",
514-
},
515-
)
516-
async def legacy_embed_single_item_command(
517-
input_data: LegacyEmbedSingleItemInput,
518-
) -> LegacyEmbedSingleItemOutput:
519-
"""
520-
Compatibility handler for pre-1.6 queued embed_single_item jobs.
521-
522-
New code submits embed_source, embed_note, or embed_insight directly. This
523-
alias lets workers drain older queues after an upgrade.
524-
"""
525-
start_time = time.time()
526-
527-
try:
528-
logger.info(
529-
f"Processing legacy embed_single_item for "
530-
f"{input_data.item_type}: {input_data.item_id}"
531-
)
532-
533-
if input_data.item_type == "source":
534-
result = await embed_source_command(
535-
EmbedSourceInput(
536-
source_id=input_data.item_id,
537-
execution_context=input_data.execution_context,
538-
)
539-
)
540-
chunks_created = result.chunks_created
541-
elif input_data.item_type == "note":
542-
result = await embed_note_command(
543-
EmbedNoteInput(
544-
note_id=input_data.item_id,
545-
execution_context=input_data.execution_context,
546-
)
547-
)
548-
chunks_created = 0
549-
elif input_data.item_type == "insight":
550-
result = await embed_insight_command(
551-
EmbedInsightInput(
552-
insight_id=input_data.item_id,
553-
execution_context=input_data.execution_context,
554-
)
555-
)
556-
chunks_created = 0
557-
else:
558-
raise ValueError(f"Invalid item_type: {input_data.item_type}")
559-
560-
return LegacyEmbedSingleItemOutput(
561-
success=result.success,
562-
item_id=input_data.item_id,
563-
item_type=input_data.item_type,
564-
chunks_created=chunks_created,
565-
processing_time=time.time() - start_time,
566-
error_message=result.error_message,
567-
)
568-
569-
except ValueError as e:
570-
processing_time = time.time() - start_time
571-
logger.error(
572-
f"Failed legacy embed_single_item for "
573-
f"{input_data.item_type} {input_data.item_id}: {e}"
574-
)
575-
return LegacyEmbedSingleItemOutput(
576-
success=False,
577-
item_id=input_data.item_id,
578-
item_type=input_data.item_type,
579-
processing_time=processing_time,
580-
error_message=str(e),
581-
)
582-
except Exception as e:
583-
logger.debug(
584-
f"Transient error in legacy embed_single_item for "
585-
f"{input_data.item_type} {input_data.item_id}: {e}"
586-
)
587-
raise
588-
589-
590-
@command(
591-
"embed_chunk",
592-
app="open_notebook",
593-
retry={
594-
"max_attempts": 5,
595-
"wait_strategy": "exponential_jitter",
596-
"wait_min": 1,
597-
"wait_max": 60,
598-
"stop_on": [ValueError, ConfigurationError],
599-
"retry_log_level": "debug",
600-
},
601-
)
602-
async def legacy_embed_chunk_command(
603-
input_data: LegacyEmbedChunkInput,
604-
) -> LegacyEmbedChunkOutput:
605-
"""
606-
Compatibility handler for pre-1.6 queued embed_chunk jobs.
607-
608-
The legacy vectorizer stored the full chunk payload in each job. Keeping this
609-
command registered prevents upgraded workers from crashing on stale queues.
610-
"""
611-
try:
612-
logger.debug(
613-
f"Processing legacy chunk {input_data.chunk_index} "
614-
f"for source {input_data.source_id}"
615-
)
616-
617-
cmd_id = get_command_id(input_data)
618-
embedding = await generate_embedding(
619-
input_data.chunk_text,
620-
content_type=ContentType.PLAIN,
621-
command_id=cmd_id,
622-
)
623-
624-
await repo_query(
625-
"""
626-
CREATE source_embedding CONTENT {
627-
"source": $source_id,
628-
"order": $order,
629-
"content": $content,
630-
"embedding": $embedding,
631-
};
632-
""",
633-
{
634-
"source_id": ensure_record_id(input_data.source_id),
635-
"order": input_data.chunk_index,
636-
"content": input_data.chunk_text,
637-
"embedding": embedding,
638-
},
639-
)
640-
641-
return LegacyEmbedChunkOutput(
642-
success=True,
643-
source_id=input_data.source_id,
644-
chunk_index=input_data.chunk_index,
645-
)
646-
647-
except ValueError as e:
648-
logger.error(
649-
f"Failed legacy embed_chunk for source {input_data.source_id} "
650-
f"chunk {input_data.chunk_index}: {e}"
651-
)
652-
return LegacyEmbedChunkOutput(
653-
success=False,
654-
source_id=input_data.source_id,
655-
chunk_index=input_data.chunk_index,
656-
error_message=str(e),
657-
)
658-
except Exception as e:
659-
logger.debug(
660-
f"Transient error in legacy embed_chunk for source "
661-
f"{input_data.source_id} chunk {input_data.chunk_index}: {e}"
662-
)
663-
raise
664-
665-
666-
@command("vectorize_source", app="open_notebook", retry=None)
667-
async def legacy_vectorize_source_command(
668-
input_data: LegacyVectorizeSourceInput,
669-
) -> LegacyVectorizeSourceOutput:
670-
"""
671-
Compatibility handler for pre-1.6 queued vectorize_source jobs.
672-
673-
The old command submitted one job per chunk. Current embed_source does the
674-
same source embedding work in one batch-aware command.
675-
"""
676-
start_time = time.time()
677-
678-
try:
679-
logger.info(f"Processing legacy vectorize_source for {input_data.source_id}")
680-
result = await embed_source_command(
681-
EmbedSourceInput(
682-
source_id=input_data.source_id,
683-
execution_context=input_data.execution_context,
684-
)
685-
)
686-
jobs_submitted = 1 if result.success else 0
687-
688-
return LegacyVectorizeSourceOutput(
689-
success=result.success,
690-
source_id=input_data.source_id,
691-
total_chunks=result.chunks_created,
692-
jobs_submitted=jobs_submitted,
693-
processing_time=time.time() - start_time,
694-
error_message=result.error_message,
695-
)
696-
697-
except ValueError as e:
698-
processing_time = time.time() - start_time
699-
logger.error(f"Failed legacy vectorize_source for {input_data.source_id}: {e}")
700-
return LegacyVectorizeSourceOutput(
701-
success=False,
702-
source_id=input_data.source_id,
703-
total_chunks=0,
704-
jobs_submitted=0,
705-
processing_time=processing_time,
706-
error_message=str(e),
707-
)
708-
except Exception as e:
709-
logger.debug(
710-
f"Transient error in legacy vectorize_source for "
711-
f"{input_data.source_id}: {e}"
712-
)
713-
raise
714-
715-
716452
@command(
717453
"create_insight",
718454
app="open_notebook",

pyproject.toml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,6 @@ ignore = [
9292
"F841", # local variable assigned but never used
9393
]
9494

95-
[tool.ruff.lint.per-file-ignores]
96-
# Streamlit files need nest_asyncio.apply() before imports
97-
"app_home.py" = ["E402"]
98-
"pages/**/*.py" = ["E402"]
99-
100-
[tool.mypy]
101-
# Exclude Streamlit UI pages from type checking
102-
[[tool.mypy.overrides]]
103-
module = "pages.*"
104-
ignore_errors = true
105-
10695
[tool.uv]
10796
# Pillow < 12.2.0 has open security advisories (PSD OOB write, FITS
10897
# decompression bomb, PDF trailer DoS). The only thing holding it back is

0 commit comments

Comments
 (0)