Repository navigation
feat(toolkit): spec 007, adopt the tools-dataset source toolkit - #41
Merged
Merged
Conversation
Spec 007 replaces the local cache, spreadsheet reader, adapter base, source registry and manifest file helpers with benchcommons-tools-dataset 0.1.0, referencing tools-dataset spec 004 as the owner of the contract. ADR 0013 records the dependency through a uv git source pinned to the tag and the upgrade procedure; ADR 0005 points to it. Refs BenchCommons/tools-dataset#5 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Lists every module and test removed with its replacement in tools-dataset v0.1.0, the baseline outputs to compare against and the task order. Refs BenchCommons/tools-dataset#5 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Declares the toolkit at ==0.1.0 with a uv git source pinned to tag v0.1.0 (ADR 0013); uv.lock records commit f3251d8. Tests check the version, the tag and the installed package. Refs BenchCommons/tools-dataset#5 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
namescommons.adapters keeps RawRecord, RawLink and DEFAULT_PACKAGE,
re-exports AdapterError, FormatError, Resource, SourceFiles, module_name,
parse_count and parse_code from datasettool.sources.adapters as the same
objects, and wraps load_adapter and check_adapter with
optional=("links",). Tests that asserted Portuguese messages of the
moved code now assert the toolkit's English messages.
Removed tests, ported to tools-dataset tests/test_adapters.py:
test_adapters.py: test_nome_do_modulo, test_carrega_o_adaptador_de_exemplo,
test_adaptador_inexistente, test_adaptador_valido, test_adaptador_invalido,
test_adaptador_sem_atributo; test_contrato_adaptador.py:
test_r2_2_parse_count, test_r2_2_parse_count_recusa_o_que_nao_conhece,
test_r2_2_parse_code_traduz_e_recusa_codigo_desconhecido,
test_r2_6_arquivo_fora_de_resources_lista_os_disponiveis,
test_r2_6_adaptador_ausente_mostra_o_caminho_esperado,
test_r2_6_adaptador_quebrado_nao_se_passa_por_ausente,
test_r2_6_pacote_de_adaptadores_inexistente.
Refs BenchCommons/tools-dataset#5
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The INE adapter reads XLS and XLSX through datasettool.sources.spreadsheet, which carries the PR #39 hardening. xlrd is no longer a direct dependency; the toolkit pins it at 2.0.2. Removed, ported to tools-dataset at v0.1.0: - src/namescommons/spreadsheet.py (datasettool.sources.spreadsheet) - tests/test_spreadsheet.py (tests/test_spreadsheet.py there); its test_r1_3_amostras_do_ine stays here as test_leitor_do_kit_le_as_amostras_do_ine with the same vectors - tests/fixtures/planilhas/tipos.xls (byte-identical tests/fixtures/spreadsheets/types.xls there) Refs BenchCommons/tools-dataset#5 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…gent The pipeline calls datasettool.sources.cache.fetch_resource with namescommons.USER_AGENT, built by make_user_agent and equal byte for byte to the old header. Retry options use the toolkit names (attempts, backoff, sleep). tools/amostra_wikidata.py imports USER_AGENT from namescommons. The toolkit refuses cache entries that resolve outside the cache, which includes symlinks: tools/bench_pipeline.py --wikidata now hard-links (or copies) the files instead of symlinking the directory. Spec 007 R4.3 records the difference; the decision is tracked in BenchCommons/tools-dataset#9. Removed, ported to tools-dataset at v0.1.0: - src/namescommons/cache.py (datasettool.sources.cache) - tests/test_cache.py, 22 tests (tests/test_cache.py there, 28) Refs BenchCommons/tools-dataset#5 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
namescommons.sources declares a RegistrySchema with the names fields (country, count_type, primary, suppression, and the optional uniform_case and strips_accents), the ADR 0001 licence list (the toolkit's ATTRIBUTION_ONLY_LICENSES plus statcan-open-licence) and the one-primary rule as a cross-entry check; the factory builds the same Source dataclass. load_sources and parse_sources keep their signatures, and SourceError is the toolkit's RegistryError. Names field messages stay in Portuguese. pyyaml is no longer a direct dependency. Removed tests, ported to tools-dataset tests/test_registry.py: test_sources.py: test_arquivo_sem_fontes, test_id_com_formato_invalido, test_campo_ausente (replaced here by test_campo_de_nomes_ausente), test_id_duplicado, test_licenca_nao_textual_vira_source_error, test_id_nao_textual_vira_source_error, test_entrada_que_nao_e_mapeamento, test_arquivo_inexistente, test_yaml_malformado, test_raiz_que_nao_e_mapeamento, test_sources_que_nao_e_lista and the retrieved, url and extra cases of test_campo_invalido; test_sources_extensoes.py: test_retrieved_com_hora_e_recusado, test_retrieved_com_hora_no_yaml_e_recusado, test_url_sem_esquema_http_e_recusada, test_url_http_e_https_aceitas, test_url_malformada_nomeia_a_fonte_em_vez_de_levantar_value_error and the adapter case of test_campo_opcional_nao_booleano. Refs BenchCommons/tools-dataset#5 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
build_manifest keeps the release format, schema_version and the sources list, and takes the files map from describe_files with counters for .csv (the toolkit's count_csv_records) and .parquet (Parquet metadata). An output file with another suffix is now a ValueError instead of being counted as CSV; the outputs only have .csv and .parquet. Removed, ported to tools-dataset tests/test_files.py: - tests/test_manifest.py (1 test, 6 cases) - test_robustez.py: test_manifesto_conta_registros_csv_e_nao_linhas_fisicas Refs BenchCommons/tools-dataset#5 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
AGENTS.md describes the toolkit in the stack and the upgrade steps, README gains a Development section, and spec 007 tasks record the verification: identical outputs on the fixtures and on the full real cache, and the small benchmark run. Refs BenchCommons/tools-dataset#5 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
11 tasks done
Spec 007 acceptance criterion 1 requires the locked install: CI now runs uv sync --locked, so a uv.lock out of sync with pyproject.toml (for example a changed toolkit tag) fails the build. README and AGENTS.md use the same command. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
test_uv_lock_aponta_a_tag now asserts the full commit of tag v0.1.0 (f3251d805f1f7839e59c5472d54833ea7bef840d), and test_kit_instalado_do_commit_da_tag checks the installed distribution's direct_url.json vcs_info.commit_id against it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
3 tasks
The upgrade procedure gains an integrity step (git ls-remote of the peeled tag must match the commit in uv.lock and in the COMMIT test constant; git tag -v must show a valid signature) and updates the test constants together with pyproject.toml, aligned with AGENTS.md. Checked for v0.1.0: f3251d8, good signature. The consequences note that non-uv installers would look the name up on PyPI, where it is not registered (BenchCommons/tools-dataset#10). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Tests import yaml directly (CI workflow and registry checks); pin it in the dev group at the toolkit's version instead of relying on the transitive dependency. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spec 007: o dataset-names passa a usar o kit de fontes
benchcommons-tools-dataset0.1.0 (importdatasettool, tagv0.1.0do tools-dataset) e fica só com o código de nomes.Refs BenchCommons/tools-dataset#5
Status: Em implementação.
O que mudou
benchcommons-tools-dataset==0.1.0com[tool.uv.sources]git fixado na tagv0.1.0; ouv.lockregistra o commitf3251d8.pyyamlexlrdsaem das dependências diretas (o kit os fixa).namescommons.adaptersmantémRawRecord,RawLinkeDEFAULT_PACKAGE, reexporta os objetos do kit (AdapterError,FormatError,Resource,SourceFiles,module_name,parse_count,parse_code) e embrulhaload_adapterecheck_adaptercomoptional=("links",).datasettool.sources.spreadsheet(com a correção do PR fix(spreadsheet): close XLSX DTD pre-scan bypass via declared encodings #39).datasettool.sources.cache.fetch_resourcecomnamescommons.USER_AGENT, igual byte a byte ao anterior.namescommons.sourcesé umRegistrySchemacom os campos de nomes (country,count_type,primary,suppression,uniform_case,strips_accents), as licenças do ADR 0001 (ATTRIBUTION_ONLY_LICENSES+statcan-open-licence) e a regra de umaprimary;SourceErroré oRegistryErrordo kit.describe_filesdo kit com contadores.csve.parquet.docs/specs/007-tools-dataset/, ADR 0013, nota no status do ADR 0005,AGENTS.md, seção Development doREADME.md,ROADMAP.md.Arquivos e testes removidos (substitutos no tools-dataset
v0.1.0, 360 testes verdes na tag)src/namescommons/cache.py->datasettool.sources.cachesrc/namescommons/spreadsheet.py->datasettool.sources.spreadsheettests/test_cache.py(22 testes) ->tests/test_cache.pyde látests/test_spreadsheet.py->tests/test_spreadsheet.pyde lá;test_r1_3_amostras_do_ineficou aqui comotest_leitor_do_kit_le_as_amostras_do_ineemtests/test_es_ine_residentes.pytests/fixtures/planilhas/tipos.xls->tests/fixtures/spreadsheets/types.xlsde lá (bytes idênticos)tests/test_manifest.py->tests/test_files.pyde látest_adapters.py, 7 emtest_contrato_adaptador.py, 11 mais 3 casos emtest_sources.py, 5 mais 1 caso emtest_sources_extensoes.py, 1 emtest_robustez.pyCritérios de aceite e verificação
uv sync --locked(também na CI) instala o kit da tag;tests/test_tools_dataset.pyconfere versão, tag, o commitf3251d805f1f7839e59c5472d54833ea7bef840dnouv.locke ocommit_iddo pacote instalado (direct_url.json).git ls-remoteda tag dá o mesmo commit, egit tag -v v0.1.0mostra assinatura válida.cache.pyespreadsheet.pynão existem (testestest_namescommons_*_nao_existe); nenhumimport yamlemsrc/.uv run pytest -q: 586 verdes, sem rede.diff -rcontramaster(0153007) não mostra diferença (8 e 109 observações).namescommons run --offlinesobre o cache real completo: 4.336.051 observações,diff -rcontramastersem diferença (89 s, 2,84 GB de pico).tools/bench_pipeline.py --observacoes 200000: OK (1,5 s ingest, 1,3 s build, 261 MB); com--wikidata: OK (1.765 MB).Diferenças aceitas (spec, R4.3): mensagens do kit em inglês; ordem das linhas numa mensagem do registro com vários erros (nenhum teste confere ordem); o cache recusa ids e nomes de arquivo inválidos; o manifesto recusa sufixo sem contador.
Decisões tomadas sozinho (com custo se estiverem erradas)
cached_pathusaresolve()), mesmo com--offlinee o arquivo presente. Registrei como item 5 de R4.3, troquei o link simbólico detools/bench_pipeline.py --wikidatapor link físico ou cópia, e abri cache: cached_path refuses symlinked cache entries tools-dataset#9 para o dono decidir. Custo: quem guardava arquivos baixados à mão como link simbólico no cache recebeValueErroraté copiá-los.namescommons.adaptersem vez de trocar os imports dos nove adaptadores. Custo: uma camada fina a mais; trocar depois é mecânico.parse_countsem invólucro: o campo padrão das mensagens passa decontagemacount. Custo: só texto de erro.SourceError = RegistryErrorpara manter o nome usado pela CLI. Custo: nenhum.pycountryestrips_accents); saíram só os genéricos. Custo: alguns testes parecidos nos dois repositórios.pyyamlexlrdfora das dependências diretas. Custo: se um módulo daqui voltar a importá-los, precisa declarar de novo.Rodada de correções da revisão
uv sync --locked(README e AGENTS.md também), teste detest_ci.pyatualizado.uv.locke conferido no pacote instalado.git ls-remoteda tag contra ouv.lock,git tag -v), constantesVERSAOeCOMMITno procedimento, alinhado com AGENTS.md; consequência sobre o nome não registrado no PyPI (PyPI name benchcommons-tools-dataset is unregistered: reserve it or document uv-only installs tools-dataset#10).pyyaml==6.0.3no grupodev, porque os testes importamyaml.test_fetch_com_falha_nomeia_a_fonteemtests/test_cli_pipeline.pypassa pela CLI (main), que não expõebackoff; o monkeypatch dedatasettool.sources.cache.BACKOFFcontinua sendo o único caminho sem mudar a CLI.Issues
🤖 Generated with Claude Code