Skip to content

Commit a128a9a

Browse files
committed
feat: make organic job execution flow sync
Impacts: validator
1 parent 32fa9d1 commit a128a9a

File tree

7 files changed

+1531
-3
lines changed

7 files changed

+1531
-3
lines changed

validator/app/src/compute_horde_validator/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def wrapped(*args, **kwargs):
134134
CONSTANCE_BACKEND = "constance.backends.database.DatabaseBackend"
135135
CONSTANCE_DATABASE_CACHE_BACKEND = "default"
136136
CONSTANCE_CONFIG = {
137+
"SYNC_ORGANIC_JOBS": (False, "SYNC_ORGANIC_JOBS", bool),
137138
"SERVING": (
138139
not env.bool("MIGRATING", default=False),
139140
"Whether this validator is serving jobs and setting weights",
@@ -257,6 +258,11 @@ def wrapped(*args, **kwargs):
257258
"Maximum number of organic jobs each miner can get scores for. Negative value means unlimited.",
258259
int,
259260
),
261+
"DYNAMIC_MAX_OVERALL_ORGANIC_JOB_TIME_LIMIT": (
262+
300,
263+
"Overall time to complete an organic job",
264+
int,
265+
),
260266
"DYNAMIC_EXECUTOR_RESERVATION_TIME_LIMIT": (
261267
7,
262268
"Time for miner to accept or decline an organic job in seconds",

validator/app/src/compute_horde_validator/validator/job_excuses.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,30 @@ async def get_expected_miner_executor_count(
114114
return 0
115115

116116
return latest_manifest.online_executor_count
117+
118+
119+
def get_expected_miner_executor_count_sync(
120+
check_time: datetime,
121+
miner_hotkey: str,
122+
executor_class: ExecutorClass,
123+
) -> int:
124+
latest_manifest = (
125+
MinerManifest.objects.filter(
126+
miner__hotkey=miner_hotkey,
127+
executor_class=executor_class,
128+
created_at__lte=check_time,
129+
)
130+
.order_by("created_at")
131+
.only("online_executor_count")
132+
.first()
133+
)
134+
135+
if latest_manifest is None:
136+
logger.warning(
137+
f"Cannot check expected miner executor count: "
138+
f"manifest not found "
139+
f"({miner_hotkey} {executor_class} {check_time})"
140+
)
141+
return 0
142+
143+
return latest_manifest.online_executor_count

validator/app/src/compute_horde_validator/validator/management/commands/debug_run_organic_job.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import shlex
22
import sys
3+
import time
34
import uuid
45

56
from asgiref.sync import async_to_sync
@@ -125,6 +126,11 @@ def handle(self, *args, **options):
125126
streaming_start_time_limit=options["streaming_start_time_limit"],
126127
)
127128

129+
if settings.DEBUG_USE_MOCK_BLOCK_NUMBER:
130+
block = 5136476 + int((time.time() - 1742076533) / 12)
131+
else:
132+
block = allowance().get_current_block()
133+
128134
job = OrganicJob.objects.create(
129135
job_uuid=str(job_request.uuid),
130136
miner=miner,
@@ -134,7 +140,7 @@ def handle(self, *args, **options):
134140
namespace=job_request.job_namespace or job_request.docker_image or None,
135141
executor_class=job_request.executor_class,
136142
job_description="User job from facilitator",
137-
block=allowance().get_current_block(),
143+
block=block,
138144
)
139145

140146
async def _run_job():

0 commit comments

Comments
 (0)