luar 0.4.0__tar.gz → 0.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {luar-0.4.0/src/luar.egg-info → luar-0.4.2}/PKG-INFO +5 -3
  2. {luar-0.4.0 → luar-0.4.2}/README.md +4 -2
  3. {luar-0.4.0 → luar-0.4.2}/pyproject.toml +1 -1
  4. {luar-0.4.0 → luar-0.4.2}/src/luar/__init__.py +1 -1
  5. {luar-0.4.0 → luar-0.4.2}/src/luar/app.py +19 -6
  6. {luar-0.4.0 → luar-0.4.2}/src/luar/cli.py +6 -2
  7. {luar-0.4.0 → luar-0.4.2/src/luar.egg-info}/PKG-INFO +5 -3
  8. {luar-0.4.0 → luar-0.4.2}/src/luar.egg-info/SOURCES.txt +1 -0
  9. luar-0.4.2/tests/test_app.py +43 -0
  10. {luar-0.4.0 → luar-0.4.2}/tests/test_laya_backend.py +12 -0
  11. {luar-0.4.0 → luar-0.4.2}/LICENSE +0 -0
  12. {luar-0.4.0 → luar-0.4.2}/setup.cfg +0 -0
  13. {luar-0.4.0 → luar-0.4.2}/src/luar/__main__.py +0 -0
  14. {luar-0.4.0 → luar-0.4.2}/src/luar/backends/__init__.py +0 -0
  15. {luar-0.4.0 → luar-0.4.2}/src/luar/backends/base.py +0 -0
  16. {luar-0.4.0 → luar-0.4.2}/src/luar/backends/laya_backend.py +0 -0
  17. {luar-0.4.0 → luar-0.4.2}/src/luar/engine.py +0 -0
  18. {luar-0.4.0 → luar-0.4.2}/src/luar/questions.py +0 -0
  19. {luar-0.4.0 → luar-0.4.2}/src/luar/report.py +0 -0
  20. {luar-0.4.0 → luar-0.4.2}/src/luar/tables.py +0 -0
  21. {luar-0.4.0 → luar-0.4.2}/src/luar.egg-info/dependency_links.txt +0 -0
  22. {luar-0.4.0 → luar-0.4.2}/src/luar.egg-info/entry_points.txt +0 -0
  23. {luar-0.4.0 → luar-0.4.2}/src/luar.egg-info/requires.txt +0 -0
  24. {luar-0.4.0 → luar-0.4.2}/src/luar.egg-info/top_level.txt +0 -0
  25. {luar-0.4.0 → luar-0.4.2}/tests/test_engine.py +0 -0
  26. {luar-0.4.0 → luar-0.4.2}/tests/test_offline.py +0 -0
  27. {luar-0.4.0 → luar-0.4.2}/tests/test_questions.py +0 -0
  28. {luar-0.4.0 → luar-0.4.2}/tests/test_tables.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: luar
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: LUAR (Local Utility for Automated Reviews): catalog spreadsheet rows with a local decision model.
5
5
  Author-email: Alexandre Alves <alexxalvess@gmail.com>
6
6
  License-Expression: MIT
@@ -166,8 +166,10 @@ Drag your file onto the **CSV or XLSX** box (or click it to choose the file).
166
166
 
167
167
  **Just want to try it?** If you installed from the repository (see [section 11](#11-related-projects-contributing-and-license)),
168
168
  pick a bundled example in **…or try an example**, or click **Sample CSV** at the top of the page
169
- to download a test spreadsheet with 20 made-up customer messages (the **README** button next to it
170
- opens this manual). Otherwise, download
169
+ to download a test spreadsheet with 20 made-up customer messages, and **Sample JSON** for the
170
+ questions that go with it (load them in **Load questions (.json)**, step 3). The **README** button
171
+ next to them opens this manual. To load both at once, pick **Amostra de teste (Sample CSV)** in the
172
+ examples menu. Otherwise, download
171
173
  [reviews.csv](https://raw.githubusercontent.com/HayateV30/luar/main/examples/reviews.csv) and
172
174
  [reviews_questions.json](https://raw.githubusercontent.com/HayateV30/luar/main/examples/reviews_questions.json)
173
175
  and load them as described in steps 2 and 3.
@@ -132,8 +132,10 @@ Drag your file onto the **CSV or XLSX** box (or click it to choose the file).
132
132
 
133
133
  **Just want to try it?** If you installed from the repository (see [section 11](#11-related-projects-contributing-and-license)),
134
134
  pick a bundled example in **…or try an example**, or click **Sample CSV** at the top of the page
135
- to download a test spreadsheet with 20 made-up customer messages (the **README** button next to it
136
- opens this manual). Otherwise, download
135
+ to download a test spreadsheet with 20 made-up customer messages, and **Sample JSON** for the
136
+ questions that go with it (load them in **Load questions (.json)**, step 3). The **README** button
137
+ next to them opens this manual. To load both at once, pick **Amostra de teste (Sample CSV)** in the
138
+ examples menu. Otherwise, download
137
139
  [reviews.csv](https://raw.githubusercontent.com/HayateV30/luar/main/examples/reviews.csv) and
138
140
  [reviews_questions.json](https://raw.githubusercontent.com/HayateV30/luar/main/examples/reviews_questions.json)
139
141
  and load them as described in steps 2 and 3.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "luar"
7
- version = "0.4.0"
7
+ version = "0.4.2"
8
8
  description = "LUAR (Local Utility for Automated Reviews): catalog spreadsheet rows with a local decision model."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -2,7 +2,7 @@
2
2
  from .engine import DEFAULT_THRESHOLD, Result, classify, run_file
3
3
  from .questions import Question, QuestionError, load_questions, parse_questions
4
4
 
5
- __version__ = "0.4.0"
5
+ __version__ = "0.4.2"
6
6
 
7
7
  __all__ = [
8
8
  "DEFAULT_THRESHOLD",
@@ -26,6 +26,7 @@ EXAMPLES = ROOT / "examples"
26
26
  # the manual and the sample ship with the repo, not the wheel: their buttons hide when missing
27
27
  READMES = {"Português": ROOT / "README.pt-BR.md", "English": ROOT / "README.md"}
28
28
  SAMPLE_CSV = EXAMPLES / "amostra_teste.csv"
29
+ SAMPLE_QUESTIONS = EXAMPLES / "amostra_teste_perguntas.json" # the questions that go with the sample
29
30
  # the READMEs link their screenshots on GitHub (so PyPI shows them); the app serves the local copies
30
31
  IMAGES = ROOT / "docs" / "images"
31
32
  REMOTE_IMAGES = "https://raw.githubusercontent.com/HayateV30/luar/main/docs/images/"
@@ -104,6 +105,13 @@ ordered scale (*experimental*: the least reliable type in our tests).
104
105
  Add a column named `expected_<id>` to your file to measure accuracy on rows you already know.
105
106
  """
106
107
 
108
+ NO_QUESTIONS = (
109
+ "There are no questions yet. In step 2, fill in at least the id and the question of one row "
110
+ "(or load a questions .json file). Trying the Sample CSV? Download Sample JSON at the top of the "
111
+ "page and drop it in \"Load questions (.json)\", or pick \"Amostra de teste (Sample CSV)\" in "
112
+ "\"…or try an example\" to load both at once."
113
+ )
114
+
107
115
 
108
116
  def _questions_to_rows(questions) -> list[list[str]]:
109
117
  rows = []
@@ -118,10 +126,13 @@ def _rows_to_questions(table) -> list:
118
126
  data = []
119
127
  for _, r in df.iterrows():
120
128
  values = ["" if pd.isna(v) else str(v).strip() for v in r.tolist()[:4]]
121
- if not any(values):
122
- continue
123
129
  qid, qtype, text, opts = values
130
+ # the table starts with a row whose type is already filled in: a type alone is not a question
131
+ if not (qid or text or opts):
132
+ continue
124
133
  data.append({"id": qid, "type": qtype.lower(), "question": text, "options": opts})
134
+ if not data:
135
+ raise QuestionError(NO_QUESTIONS)
125
136
  return parse_questions(data)
126
137
 
127
138
 
@@ -170,6 +181,7 @@ EXAMPLE_SETS = {
170
181
  "English reviews": ("reviews.csv", "reviews_questions.json"),
171
182
  "English reviews: severity (score)": ("reviews.csv", "reviews_severity_question.json"),
172
183
  "Avaliações em português": ("avaliacoes.csv", "avaliacoes_perguntas.json"),
184
+ "Amostra de teste (Sample CSV)": ("amostra_teste.csv", "amostra_teste_perguntas.json"),
173
185
  }
174
186
 
175
187
 
@@ -231,10 +243,11 @@ def build() -> gr.Blocks:
231
243
  gr.Markdown("# LUAR")
232
244
  with gr.Row(elem_id="luar-actions"):
233
245
  readme_btn = gr.Button("README", variant="secondary", size="md", visible=bool(readmes))
234
- gr.DownloadButton(
235
- "Sample CSV", value=str(SAMPLE_CSV) if SAMPLE_CSV.exists() else None,
236
- variant="secondary", size="md", visible=SAMPLE_CSV.exists(),
237
- )
246
+ for label, path in (("Sample CSV", SAMPLE_CSV), ("Sample JSON", SAMPLE_QUESTIONS)):
247
+ gr.DownloadButton(
248
+ label, value=str(path) if path.exists() else None,
249
+ variant="secondary", size="md", visible=path.exists(),
250
+ )
238
251
  gr.Markdown(TAGLINE, elem_id="luar-tagline")
239
252
  with gr.Sidebar(label="README", open=False, position="right", width="min(760px, 92vw)") as manual:
240
253
  with gr.Tabs():
@@ -44,11 +44,14 @@ def _cmd_run(args) -> int:
44
44
  return 0
45
45
 
46
46
 
47
+ DOWNLOAD_DEFAULT = ("multilingual", "english") # the two checkpoints `auto` picks from
48
+
49
+
47
50
  def _cmd_download(args) -> int:
48
51
  from .backends.laya_backend import download_checkpoints
49
52
 
50
53
  print("Downloading the Laya models (about 1.5 GB, only once)…", file=sys.stderr)
51
- for folder in download_checkpoints(checkpoints=tuple(args.checkpoints)):
54
+ for folder in download_checkpoints(checkpoints=tuple(args.checkpoints or DOWNLOAD_DEFAULT)):
52
55
  print(f" {folder}")
53
56
  print("Done: LUAR now runs offline.")
54
57
  return 0
@@ -87,7 +90,8 @@ def main(argv: list[str] | None = None) -> int:
87
90
  p.set_defaults(func=_cmd_columns)
88
91
 
89
92
  p = sub.add_parser("download", help="fetch the Laya models now, so LUAR works offline afterwards")
90
- p.add_argument("checkpoints", nargs="*", default=["multilingual", "english"],
93
+ # no list default: before Python 3.14, argparse checks a list default against `choices` as one value
94
+ p.add_argument("checkpoints", nargs="*",
91
95
  choices=["multilingual", "english", "typed-decisions"],
92
96
  help="which models (default: multilingual and english, the ones `auto` picks from)")
93
97
  p.set_defaults(func=_cmd_download)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: luar
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: LUAR (Local Utility for Automated Reviews): catalog spreadsheet rows with a local decision model.
5
5
  Author-email: Alexandre Alves <alexxalvess@gmail.com>
6
6
  License-Expression: MIT
@@ -166,8 +166,10 @@ Drag your file onto the **CSV or XLSX** box (or click it to choose the file).
166
166
 
167
167
  **Just want to try it?** If you installed from the repository (see [section 11](#11-related-projects-contributing-and-license)),
168
168
  pick a bundled example in **…or try an example**, or click **Sample CSV** at the top of the page
169
- to download a test spreadsheet with 20 made-up customer messages (the **README** button next to it
170
- opens this manual). Otherwise, download
169
+ to download a test spreadsheet with 20 made-up customer messages, and **Sample JSON** for the
170
+ questions that go with it (load them in **Load questions (.json)**, step 3). The **README** button
171
+ next to them opens this manual. To load both at once, pick **Amostra de teste (Sample CSV)** in the
172
+ examples menu. Otherwise, download
171
173
  [reviews.csv](https://raw.githubusercontent.com/HayateV30/luar/main/examples/reviews.csv) and
172
174
  [reviews_questions.json](https://raw.githubusercontent.com/HayateV30/luar/main/examples/reviews_questions.json)
173
175
  and load them as described in steps 2 and 3.
@@ -18,6 +18,7 @@ src/luar.egg-info/top_level.txt
18
18
  src/luar/backends/__init__.py
19
19
  src/luar/backends/base.py
20
20
  src/luar/backends/laya_backend.py
21
+ tests/test_app.py
21
22
  tests/test_engine.py
22
23
  tests/test_laya_backend.py
23
24
  tests/test_offline.py
@@ -0,0 +1,43 @@
1
+ """Web interface helpers (need the `ui` extra)."""
2
+ import pytest
3
+
4
+ from luar.questions import QuestionError, load_questions
5
+ from luar.tables import read_table
6
+
7
+ from .conftest import EXAMPLES
8
+
9
+ app = pytest.importorskip("luar.app")
10
+
11
+
12
+ def test_the_starting_row_is_not_a_question():
13
+ """The questions table opens with only the type filled in; that row must be ignored."""
14
+ real = ["topic", "choice", "What is it about?", "a; b"]
15
+ assert [q.id for q in app._rows_to_questions([real, ["", "choice", "", ""]])] == ["topic"]
16
+ assert [q.id for q in app._rows_to_questions([["", "noul", "", ""], real])] == ["topic"]
17
+
18
+
19
+ def test_no_questions_explains_what_to_do():
20
+ for table in ([["", "choice", "", ""]], [["", "", "", ""]]):
21
+ with pytest.raises(QuestionError, match="no questions yet"):
22
+ app._rows_to_questions(table)
23
+
24
+
25
+ def test_half_written_row_still_reports_the_missing_id():
26
+ with pytest.raises(QuestionError, match="Invalid question id"):
27
+ app._rows_to_questions([["", "choice", "What is it about?", "a; b"]])
28
+
29
+
30
+ def test_sample_buttons_offer_a_matching_pair():
31
+ """Sample CSV and Sample JSON must work together: every question has its answer column."""
32
+ df, _ = read_table(app.SAMPLE_CSV)
33
+ questions = load_questions(app.SAMPLE_QUESTIONS)
34
+ assert questions and all(f"expected_{q.id}" in df.columns for q in questions)
35
+
36
+
37
+ def test_every_example_set_loads_and_matches_its_answer_key():
38
+ for name, (data, questions) in app.EXAMPLE_SETS.items():
39
+ df, _ = read_table(EXAMPLES / data)
40
+ for q in load_questions(EXAMPLES / questions):
41
+ assert f"expected_{q.id}" in df.columns, f"{name}: no expected_{q.id}"
42
+ file, rows = app.on_example(name)
43
+ assert [r[0] for r in rows] == [q.id for q in load_questions(EXAMPLES / questions)]
@@ -76,3 +76,15 @@ def test_missing_laya_gives_install_hint(monkeypatch, capsys):
76
76
  code = cli_main(["run", str(EXAMPLES / "reviews.csv"), "-q", str(EXAMPLES / "reviews_questions.json"),
77
77
  "-c", "review"])
78
78
  assert code == 2 and "pip install" in capsys.readouterr().err
79
+
80
+
81
+ def test_download_command(monkeypatch):
82
+ """`luar download` with no argument is what the manual tells people to run."""
83
+ import luar.backends.laya_backend as laya_backend
84
+ from luar.cli import main as cli_main
85
+
86
+ asked = []
87
+ monkeypatch.setattr(laya_backend, "download_checkpoints", lambda checkpoints: asked.append(checkpoints) or [])
88
+ assert cli_main(["download"]) == 0
89
+ assert cli_main(["download", "english"]) == 0
90
+ assert asked == [("multilingual", "english"), ("english",)]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes