Skip to content

Issue976#978

Open
lior-antonov wants to merge 21 commits into
masterfrom
Issue976
Open

Issue976#978
lior-antonov wants to merge 21 commits into
masterfrom
Issue976

Conversation

@lior-antonov

@lior-antonov lior-antonov commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

closes #976

Ilay Falach and others added 21 commits June 17, 2026 11:08
The eager getToolkit(EXPERIMENT) call pulled geopandas+xarray+pint (~290ms)
on every import. experimentTK is now None until explicitly requested.
…935)

toolkitHome, Project, datatypes, ToolkitHome, and autocache utilities are now
populated on first access rather than at import time. 'import hera' drops from
~610ms to ~22ms. All consumer patterns continue to work via PEP 562 __getattr__.
Zero heavy libs (pandas, mongoengine, geopandas, ...) loaded until first use.
…port (#935)

datalayer/document: createDBConnection loop moved from module level into
_ensure_connections() called by getDBObject() on first use. This removes the
DB connection overhead from any import path that doesn't touch the datalayer.

datalayer/project: remove unused 'from hera import toolkit' (toolkit was only
referenced in docstring text, not in any actual code). This also breaks the
circular import hera.toolkit <-> hera.datalayer that required toolkit to be
imported before datalayer.
Removes module-level 'import pandas as pd'. The two methods that use pandas
(getDataSourceTable and the toolkit registry builder) now import it locally.
Return type annotation uses string form to avoid class-body import.
Replace module-level imports with _LazyModule proxies. Importing the module's
public constants (WSG84, ITM, convertCRS) is now instant. Heavy libs are loaded
on first attribute access when a GIS operation is actually performed.
)

datahandler: numpy and pandas are now _LazyModule proxies — they only load
when a handler actually reads/writes data.

project: import pandas inside getDescTable(); import tqdm inside the two
export/load progress-bar branches. Both are ~300ms+ and only needed at
runtime, not import time.
experiment.py: remove module-level 'import pandas as pd'; defer
experimentPresentation/experimentAnalysis imports to experimentHome.__init__.
WSG84/ITM kept at module level (integer constants; GIS utils now fast).

presentation.py: replace numpy/pandas/jinja2 with _LazyModule proxies.

analysis.py: replace 'import pandas' with _LazyModule proxy.

The experiment toolkit's heavy deps (argos + pandas/numpy) are loaded on first
getToolkit('experiment') call, not at 'import hera' time.
…935)

CLI entry points: moved all 'from hera.*' imports inside if __name__ == '__main__'
so module-level code is only stdlib (argparse, argcomplete, logging). Applies to:
hera-project, hera-openFoam, hera-workflows, hera-GIS, hera-LSM,
hera-riskassessment, hera-experiment, hera-radiosonde.

CLI module files: added _setup()/_initialized pattern to defer heavy imports
to first function call, not module import:
  - hera/utils/data/CLI.py (toolkitHome, datalayer, pandas, tabulate)
  - hera/measurements/GIS/CLI.py (pandas, toolkitHome, WSG84/ITM)
  - hera/simulations/LSM/CLI.py (ToolkitHome, toolkitHome, loadJSON)

hera/riskassessment/__init__.py: replaced eager imports with PEP 562 __getattr__
so 'from hera.riskassessment import CLI' no longer pulls geopandas/scipy/matplotlib.

Result (--help response time):
  hera-project:      58ms  (was 736ms)
  hera-GIS:          48ms  (was 936ms)
  hera-workflows:    56ms  (already fast)
  hera-LSM:          51ms  (was 671ms)
  hera-riskassessment: 50ms (was 1820ms)
… in CLI files refs #935

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…get the exact doument that would be saved in the DB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make lsm.old not save to db on fail

1 participant