[Refactor]: Make shared ingestion script helpers public

Aperta
#479 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
32/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start with the cross-imports in backend/app/scripts/ingestion/archive_client.py and archive_ingestor_core.py, then run the grep in the acceptance criteria to list every _-prefixed import. Decide per helper whether it is renamed or moved, and update the test imports and patch targets to match. Done means the grep returns nothing outside the PR's listed exceptions and make backend-test and make pre-commit-run pass. The module-split choices need maintainer agreement before you start.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

refactor
Is your feature request related to a problem?

Modules in backend/app/scripts/ingestion/ import about 100 private (_-prefixed) names from each other. These helpers are shared APIs in practice, but their names say otherwise. That makes it unclear which functions are safe to change, and the call graph is hard to follow.

The heaviest dependencies:

Provider Importers Examples
archive_client.py hpc_upload_archive_ingestor, nersc_archive_ingestor, archive_source_directories, archive_workflow, backfill/metadata _build_config_from_env, _fetch_ingestion_state, _fetch_archive_checkpoints, _build_json_request, _http_request_error
archive_ingestor_core.py Almost every script _log_event (12 imports), _log_multiline_event
archive_workflow.py hpc_upload_archive_ingestor, nersc_archive_ingestor _validate_run_preconditions, _handle_ingest_run, _finalize_archive_checkpoints
archive_discovery.py archive_workflow, archive_source_directories, hpc_upload_archive_ingestor _scan_archive, _settled_archive_snapshot_keys, _build_processed_ids_by_key
archive_layout.py archive_discovery, archive_source_directories, backfill/metadata, v3_data/lcrc_v3_archive_ingestor _case_identity_key, _filter_archive_walk_dirnames

Scripts also reach into app/features and app/common for private names: features.ingestion.ingest._normalize_path_candidate, private helpers in features.ingestion.parsers.parser, and common.utils._normalize_hpc_username.

Related: #306 (feature module split).

Describe the solution you'd like
  • Make every helper imported by another module public (drop the _ prefix). Keep helpers used in only one module private.
  • Where a provider module is mainly shared helpers (for example, archive_client.py and the logging helpers in archive_ingestor_core.py), consider moving those helpers into a focused module such as archive_logging.py or archive_http.py instead of only renaming them.
  • Make common.utils._normalize_hpc_username and features.ingestion.ingest._normalize_path_candidate public, or move them to a shared utility module.
  • Update test imports and patch(...) targets for renamed names.
Acceptance criteria
  • No module under app/scripts/ingestion/ imports a _-prefixed name from another module. Verify with:

    grep -rnE "^from app\.[a-z_.]+ import .*\b_[a-z]" app/scripts/ingestion
    

    The output should be empty, apart from any exceptions listed in the PR description.

  • No behavior change: make backend-test and make pre-commit-run pass.

Describe alternatives you've considered
  • Keep the names private and document the module boundaries. This doesn't fix the misleading names or stop accidental breakage.
  • Merge the scripts into fewer, larger modules. This removes the cross-imports but makes the files bigger, which is the opposite of what we want.
Additional context

The same pattern appears outside scripts: app.core.logger._setup_custom_logger and _setup_root_logger are imported across the app. Include them if the change stays small.

Lingua principale
Python
Stelle
2
Fork
2
Merge medio
12h 49m
PR unite (30g)
30

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di E3SM-Project/simboard

Tutte le issue di E3SM-Project/simboard

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.