Skip to content

fix(client): pick the right path level for the dataset in get_local_hierarchy - #359

Merged
luabida merged 1 commit into
AlertaDengue:mainfrom
devgtv:fix/client-local-hierarchy
Sep 30, 2026
Merged

luabida merged 1 commit into
AlertaDengue:mainfrom
devgtv:fix/client-local-hierarchy

Conversation

@devgtv

@devgtv devgtv commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Summary

_get_dest_path (pysus/api/client.py:349) nests a grouped file one directory deeper than an ungrouped one:

downloads/<client>/<dataset>/<group>/<name>   # has a group
downloads/<client>/<dataset>/<name>          # no group

so the dataset is parts[-3] in the first case and parts[-2] in the second. The ternary had them the other way round:

dataset = parts[-2] if has_group else parts[-3]

Impact

Every grouped file was keyed under its group name and every ungrouped one under the client name, so get_local_hierarchy returned

{"FTP": {"DC": {"DC": [...]}, "ftp": {"": [...]}}}

instead of

{"FTP": {"sinan": {"DC": [...], "": [...]}}}

The documented return shape is {client: {dataset: {group: [files]}}} — neither the dataset nor the group level was correct.

This is the second half of the get_local_hierarchy breakage; the other half is #358 (group was never persisted, so has_group was always False and every file landed on the client name). Both are needed for a correct tree.

Tests

Added 4 tests covering a grouped file, an ungrouped file, both shapes sharing one dataset, and two clients whose names must not be mistaken for datasets. All 4 fail against the previous code.

  • 1736 passed, 6 skipped
  • black and isort clean

…ierarchy

`_get_dest_path` nests a grouped file one directory deeper than an
ungrouped one:

    downloads/<client>/<dataset>/<group>/<name>   # has a group
    downloads/<client>/<dataset>/<name>          # no group

so the dataset is `parts[-3]` in the first case and `parts[-2]` in the
second. The ternary had them the other way round:

    dataset = parts[-2] if has_group else parts[-3]

Every grouped file was keyed under its group name and every ungrouped
one under the client name, so `get_local_hierarchy` returned
`{"FTP": {"DC": {...}}}` instead of `{"FTP": {"sinan": {"DC": {...}}}}`.
@fccoelho
fccoelho requested a review from luabida September 30, 2026 10:35
@codecov-commenter

codecov-commenter commented Sep 30, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@24f736b). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #359   +/-   ##
=======================================
  Coverage        ?   97.02%           
=======================================
  Files           ?      180           
  Lines           ?    22731           
  Branches        ?        0           
=======================================
  Hits            ?    22054           
  Misses          ?      677           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@luabida
luabida merged commit 3a8d33c into AlertaDengue:main Sep 30, 2026
15 checks passed
devgtv added a commit to devgtv/PySUS that referenced this pull request Sep 30, 2026
Resolves the conflict with AlertaDengue#359 (already merged), which appends test
classes to the same two files.

The two fixes touch different regions of pysus/api/client.py and merge
cleanly there.

pysus/tests/api/test_client.py conflicted because AlertaDengue#358 and AlertaDengue#359 both
append at end of file. Beyond concatenating them, this fixes two
problems that AlertaDengue#359 introduced when it merged:

- It defined a second `TestGetLocalHierarchy`, shadowing the existing
  class of the same name, so
  `test_get_local_hierarchy_all_branches` silently stopped being
  collected. It is now `TestGetLocalHierarchyDatasetLevel` and both
  classes run (51 tests in this file, up from 46).

- That existing test asserted the *buggy* output of AlertaDengue#359: it expected a
  grouped file under its group name (`ftp_dict["DC"]`) and an ungrouped
  one under the client name (`ftp_dict["ftp"]`). Its assertions are
  updated to the corrected shape, and tightened: the old ones happened
  to pass partly by coincidence, so it now also pins down the
  directory record, the ungrouped bucket, and that "DC", "ftp" and
  "short" are not dataset keys.
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.11.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants