# HG changeset patch # User drewp@bigasterisk.com # Date 1720761101 25200 # Node ID b9c2b7fedbcd20976eea6985c278cec9e87df327 # Parent 403eff4a16c8ac6a8ad1f357b2f88aa45c91c5ef fix up deployment and connect ui to server again diff -r 403eff4a16c8 -r b9c2b7fedbcd Dockerfile.server --- a/Dockerfile.server Thu Jul 11 21:32:24 2024 -0700 +++ b/Dockerfile.server Thu Jul 11 22:11:41 2024 -0700 @@ -8,4 +8,4 @@ RUN pdm run python -c 'import nltk; nltk.download("punkt")' COPY env ./ -COPY scobot/** ./scobot/ \ No newline at end of file +COPY scobot/ ./scobot/ diff -r 403eff4a16c8 -r b9c2b7fedbcd pyproject.toml --- a/pyproject.toml Thu Jul 11 21:32:24 2024 -0700 +++ b/pyproject.toml Thu Jul 11 22:11:41 2024 -0700 @@ -33,4 +33,5 @@ run_prefect_server = "prefect server start" run_build_flow = "python -c 'from scobot.index.build_index_flow import buildIndex; buildIndex.serve(buildIndex.__name__)'" start_build = "prefect deployment run buildIndex/buildIndex" -run_local_deploy = "fastapi dev --host 0.0.0.0 --port 8001 scobot" \ No newline at end of file +run_local_deploy = "fastapi dev --host 0.0.0.0 --port 8001 scobot" +run_local_vite = {shell = "(cd web; pnpm exec vite)"} diff -r 403eff4a16c8 -r b9c2b7fedbcd scobot/index/build_index_flow.py --- a/scobot/index/build_index_flow.py Thu Jul 11 21:32:24 2024 -0700 +++ b/scobot/index/build_index_flow.py Thu Jul 11 22:11:41 2024 -0700 @@ -91,7 +91,7 @@ log = get_run_logger() scobot.index.access.log = log - index = SearchIndex(Path('/tmp/scoindex')) + index = SearchIndex(Path('data/index')) for url in meetingListUrls(): mtgs = cast(list[MeetingRow], getCityMutableJson(url)) log.info(f'got {len(mtgs)=}') diff -r 403eff4a16c8 -r b9c2b7fedbcd scobot/service/__init__.py diff -r 403eff4a16c8 -r b9c2b7fedbcd scobot/service/query.py --- a/scobot/service/query.py Thu Jul 11 21:32:24 2024 -0700 +++ b/scobot/service/query.py Thu Jul 11 22:11:41 2024 -0700 @@ -1,3 +1,4 @@ +import html from scobot.index.access import SearchIndexRO from whoosh.qparser import QueryParser import json @@ -47,7 +48,7 @@ @asynccontextmanager async def lifespan(app: FastAPI): - app.state.index = SearchIndexRO('/tmp/scoindex') + app.state.index = SearchIndexRO('data/index') yield app = FastAPI(lifespan=lifespan) @@ -58,5 +59,10 @@ query = QueryParser("phrase", index.ix.schema).parse(q) pprint(query) - results = list(index.searcher.search(query)) - return {"results": results} + results = index.searcher.search(query) + docs=[] + for res in results: + doc=dict(res) + doc['snippetHtml'] = html.escape(doc['phrase']) + docs.append(doc) + return {"results": docs} diff -r 403eff4a16c8 -r b9c2b7fedbcd web/src/main.ts --- a/web/src/main.ts Thu Jul 11 21:32:24 2024 -0700 +++ b/web/src/main.ts Thu Jul 11 22:11:41 2024 -0700 @@ -5,6 +5,12 @@ import { unsafeHTML } from "lit/directives/unsafe-html.js"; setBasePath("@fs/opt/node_modules/@shoelace-style/shoelace/dist"); +interface Doc { + sourceTitle: string + phrase: string + snippetHtml: string +} + @customElement("sco-search-page") export class ScoSearchPage extends LitElement { static styles = [ @@ -52,7 +58,7 @@ `, ]; @state() query: string = "climate"; - @state() results: Object[] = []; + @state() results: Doc[] = []; @state() queryError: string = ""; @queryAsync("sl-textarea") queryEl?: Promise; protected async firstUpdated(_changedProperties: PropertyValueMap | Map) { @@ -114,10 +120,10 @@
${this.results.map( - (r) => - html`
${r.title}
+ (r: Doc) => + html`
${r.sourceTitle}
${unsafeHTML(r.snippetHtml)}
` - )} + )}
Matching results: ${this.results.length}