Commit a1a624db06f7bdcdbbb25c7cb93c730f74be5177

Authored by hitier
1 parent 5cbe3aeb
Exists in rhitier-dev

Enhance time counting at data fetching

Showing 1 changed file with 9 additions and 5 deletions   Show diff stats
web/run.py
... ... @@ -903,9 +903,9 @@ def generate_csv_contents(target_slug, input_slug, started_at, stopped_at):
903 903  
904 904  
905 905 def generate_csv_contents_spz(target_slug, input_slug, started_at, stopped_at):
906   - now = datetime.datetime.now()
  906 + global_now = datetime.datetime.now()
907 907 hp_logger.debug(
908   - f"Generating csv content with Speasy for {target_slug}/{input_slug} between {stopped_at} {stopped_at}")
  908 + f"Generating csv content with Speasy for {target_slug}/{input_slug} between {started_at} {stopped_at}")
909 909 target_config = get_target_config(target_slug)
910 910 plasma_params = {}
911 911 for plasma_struct in target_config['models'][input_slug]:
... ... @@ -918,11 +918,15 @@ def generate_csv_contents_spz(target_slug, input_slug, started_at, stopped_at):
918 918 hp_logger.info(f"Aggregating dataframes speazy parameters for '{input_slug}' to '{target_slug}'")
919 919 list_df = []
920 920 for _name, _id in parameters_dict.items():
921   - hp_logger.debug(f"Getting parameter id '{_id}' for '{_name}'")
  921 + hp_logger.debug(f"Getting parameter id '{_id}' for '{_name}' ...")
  922 + param_now = datetime.datetime.now()
922 923 amda_dataset = amda.get_data(_id, started_at, stopped_at)
923 924 if amda_dataset is None:
  925 + hp_logger.debug(f" ... No data")
924 926 continue
925 927 _df = amda_dataset.to_dataframe()
  928 + param_then = datetime.datetime.now()
  929 + hp_logger.debug(f" ... Got {len(_df)} in {param_then - param_now}")
926 930 if _name == 'xy_v':
927 931 _df = _df.rename(columns={_df.columns[0]: 'vrad', _df.columns[1]: 'vtan'})
928 932 elif _name == 'xy_hee':
... ... @@ -961,8 +965,8 @@ def generate_csv_contents_spz(target_slug, input_slug, started_at, stopped_at):
961 965 final_df = final_df[cols_ordered]
962 966 final_df.index.name = 'time'
963 967  
964   - then = datetime.datetime.now()
965   - hp_logger.debug(f"Took {then - now} to generate")
  968 + global_then = datetime.datetime.now()
  969 + hp_logger.debug(f"Took {global_then - global_now} to generate")
966 970  
967 971 return final_df.to_csv(date_format='%Y-%m-%dT%H:%M:%S+00:00', float_format="%.5f",
968 972 header=True,
... ...