MCPcopy Create free account
hub / github.com/ResearAI/DeepReviewer-v2 / cmd_submit

Function cmd_submit

main.py:108–154  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

106
107
108def cmd_submit(args: argparse.Namespace) -> int:
109 settings = get_settings()
110 pdf_path = Path(args.pdf).expanduser().resolve()
111 if not pdf_path.exists() or not pdf_path.is_file():
112 _print_json({'status': 'error', 'message': f'PDF not found: {pdf_path}'})
113 return 2
114 file_size = int(pdf_path.stat().st_size)
115 if file_size <= 0:
116 _print_json({'status': 'error', 'message': f'PDF is empty: {pdf_path}'})
117 return 2
118 if file_size > int(settings.max_pdf_bytes):
119 _print_json(
120 {
121 'status': 'error',
122 'message': (
123 f'PDF too large: {file_size} bytes, '
124 f'max allowed {int(settings.max_pdf_bytes)} bytes'
125 ),
126 }
127 )
128 return 2
129
130 job = _create_job(pdf_path, args.title)
131 _spawn_worker(str(job.id))
132
133 wait_seconds = args.wait_seconds
134 if wait_seconds is None:
135 wait_seconds = settings.submit_default_wait_seconds
136 wait_seconds = max(0, int(wait_seconds))
137
138 deadline = time.time() + wait_seconds
139 poll_interval = max(0.3, float(settings.submit_poll_interval_seconds))
140
141 latest = job
142 while time.time() <= deadline:
143 current = load_job_state(job.id)
144 if current is not None:
145 latest = current
146 if latest.status in {JobStatus.completed, JobStatus.failed}:
147 break
148 if wait_seconds == 0:
149 break
150 time.sleep(poll_interval)
151
152 completed = latest.status == JobStatus.completed
153 _print_json(_submit_response(latest, completed=completed))
154 return 0
155
156
157def cmd_status(args: argparse.Namespace) -> int:

Callers

nothing calls this directly

Calls 6

get_settingsFunction · 0.90
load_job_stateFunction · 0.90
_print_jsonFunction · 0.85
_create_jobFunction · 0.85
_spawn_workerFunction · 0.85
_submit_responseFunction · 0.85

Tested by

no test coverage detected