Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auto_sizing/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def run(
raise Exception("Either provide a config file or run auto sizing presets.")

analysis_executor = AnalysisExecutor(
target_slug=target_slug,
target_slug=target_slug if target_slug else All,
project_id=project_id,
dataset_id=dataset_id,
bucket=bucket,
Expand Down
19 changes: 15 additions & 4 deletions auto_sizing/size_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from mozanalysis.experiment import TimeLimits
from mozanalysis.frequentist_stats.sample_size import z_or_t_ind_sample_size_calc
from mozanalysis.sizing import HistoricalTarget
from numpy import nan, ndarray
from pandas import DataFrame

import auto_sizing.errors as errors
Expand Down Expand Up @@ -86,7 +87,9 @@ def calculate_metrics(
)
)

df = self.bigquerycontext.run_query(metrics_sql, metrics_table_name).to_dataframe()
df = self.bigquerycontext.run_query(
metrics_sql, metrics_table_name, replace_tables=True
).to_dataframe()
delete_bq_table(
self.bigquerycontext.fully_qualify_table_name(targets_table_name), self.project
)
Expand All @@ -106,8 +109,12 @@ def calculate_sample_sizes(
metrics_results = {
key: {
"number_of_clients_targeted": res[key]["number_of_clients_targeted"],
"sample_size_per_branch": res[key]["sample_size_per_branch"],
"population_percent_per_branch": res[key]["population_percent_per_branch"],
"sample_size_per_branch": nan
if isinstance(res[key]["sample_size_per_branch"], ndarray)
else res[key]["sample_size_per_branch"],
"population_percent_per_branch": nan
if type(res[key]["population_percent_per_branch"], ndarray)
else res[key]["population_percent_per_branch"],
}
for key in res.keys()
}
Expand All @@ -124,7 +131,7 @@ def publish_results(self, result_dict: Dict[str, Any], current_date: str) -> Non
path.write_text(json.dumps(result_dict))
print(f"Results saved at {path}")

else:
elif self.bucket:
export_sample_size_json(
self.project,
self.bucket,
Expand All @@ -133,6 +140,10 @@ def publish_results(self, result_dict: Dict[str, Any], current_date: str) -> Non
current_date,
)

path = Path(__file__).parent / f"{self.config.target_slug}.json"
path.write_text(json.dumps(result_dict))
print(f"Results saved at {path}")

def run(self, current_date: datetime) -> None:
time_limits = self._validate_requested_timelimits(current_date)

Expand Down