Skip to content

Commit

Permalink
Rename command to clear_schedules
Browse files Browse the repository at this point in the history
  • Loading branch information
hellais committed Sep 6, 2024
1 parent 9c6ba01 commit 87f6d62
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 33 deletions.
8 changes: 3 additions & 5 deletions oonipipeline/src/oonipipeline/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
run_backfill,
run_create_schedules,
run_status,
run_reschedule,
run_clear_schedules,
)
from oonipipeline.temporal.workers import start_workers

Expand Down Expand Up @@ -196,7 +196,7 @@ def schedule(
@cli.command()
@probe_cc_option
@test_name_option
def reschedule(
def clear_schedules(
probe_cc: List[str],
test_name: List[str],
):
Expand All @@ -210,11 +210,9 @@ def reschedule(
temporal_tls_client_key_path=config.temporal_tls_client_key_path,
)

run_reschedule(
run_clear_schedules(
probe_cc=probe_cc,
test_name=test_name,
clickhouse_url=config.clickhouse_url,
data_dir=config.data_dir,
temporal_config=temporal_config,
)

Expand Down
20 changes: 6 additions & 14 deletions oonipipeline/src/oonipipeline/temporal/client_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ScheduleIdMap,
schedule_all,
schedule_backfill,
reschedule_all,
clear_schedules,
)

from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
Expand Down Expand Up @@ -154,23 +154,19 @@ async def create_schedules(
)


async def reschedule(
async def execute_clear_schedules(
probe_cc: List[str],
test_name: List[str],
clickhouse_url: str,
data_dir: str,
temporal_config: TemporalConfig,
) -> ScheduleIdMap:
) -> List[str]:
log.info(f"rescheduling everything")

client = await temporal_connect(temporal_config=temporal_config)

return await reschedule_all(
return await clear_schedules(
client=client,
probe_cc=probe_cc,
test_name=test_name,
clickhouse_url=clickhouse_url,
data_dir=data_dir,
)


Expand Down Expand Up @@ -255,20 +251,16 @@ def run_create_schedules(
print("shutting down")


def run_reschedule(
def run_clear_schedules(
probe_cc: List[str],
test_name: List[str],
clickhouse_url: str,
data_dir: str,
temporal_config: TemporalConfig,
):
try:
asyncio.run(
reschedule(
execute_clear_schedules(
probe_cc=probe_cc,
test_name=test_name,
clickhouse_url=clickhouse_url,
data_dir=data_dir,
temporal_config=temporal_config,
)
)
Expand Down
21 changes: 7 additions & 14 deletions oonipipeline/src/oonipipeline/temporal/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,26 +189,19 @@ async def schedule_all(
return schedule_id_map


async def reschedule_all(
async def clear_schedules(
client: TemporalClient,
probe_cc: List[str],
test_name: List[str],
clickhouse_url: str,
data_dir: str,
) -> ScheduleIdMap:
) -> List[str]:
schedule_ids = []
existing_schedules = await list_existing_schedules(
client=client, probe_cc=probe_cc, test_name=test_name
)
for schedule_id in existing_schedules.observations + existing_schedules.analysis:
await client.get_schedule_handle(schedule_id).delete()

return await schedule_all(
client=client,
probe_cc=probe_cc,
test_name=test_name,
clickhouse_url=clickhouse_url,
data_dir=data_dir,
)
for sid in existing_schedules.observations + existing_schedules.analysis:
log.info(f"deleting schedule {sid}")
schedule_ids.append(await client.get_schedule_handle(sid).delete())
return schedule_ids


async def schedule_backfill(
Expand Down

0 comments on commit 87f6d62

Please sign in to comment.