Skip to content

Commit e013321

Browse files
authored
Merge pull request #74 from arXiv/SUBMISSION-128-pdf-only
SUBMISSION-128: pdf only
2 parents af50490 + 172cd91 commit e013321

15 files changed

Lines changed: 187 additions & 54 deletions

File tree

README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,22 @@ arXiv paper submission system
44
## Install & use
55

66
```bash
7-
# Start the compiler api:
8-
gcloud run services proxy tex2pdf-api-default --project arxiv-development --region us-central1 --port=9001
9-
10-
# Install gcld3 dependencies needed by arxiv-base metadata checks
11-
# On linux:
7+
# On linux, Install gcld3 dependencies needed by arxiv-base metadata checks
128
sudo apt-get install cmake libprotobuf-dev protobuf-compiler
13-
uv sync
14-
# On mac, you need a version of protobuf <= 21:
15-
brew search protobuf
9+
10+
# On mac, you need a version of protobuf <= 21
1611
brew install protobuf@21
1712

1813
pyenv shell 3.11 # or similar
1914
source .venv/bin/activate
2015
uv sync
2116

22-
# this will give you an Authorization token, save that and use a browser extension
23-
# like modheader to add Authorization=eyJhb...
17+
# Generate an Authorization token:
2418
uv run python submit_ce/make_test_db.py bootstrap_db
2519

20+
# Use a browser extension like modheader to send the token for localhost
21+
# add Authorization=eyJhb...
22+
2623
uv run python local_dev.py
2724
open http://localhost:8000
2825
```
@@ -39,4 +36,4 @@ open http://localhost:8000
3936
gcloud auth configure-docker gcr.io # only needed once
4037
docker build . -t gcr.io/arxiv-development/submit-ce/submit-ce-ui
4138
docker push gcr.io/arxiv-development/submit-ce/submit-ce-ui
42-
```
39+
```

submit_ce/domain/uploads.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ class Workspace(BaseModel):
102102
lifecycle: UploadLifecycleStates
103103
locked: bool
104104
identifier: str
105-
source_format: SourceFormat = SourceFormat.UNKNOWN
106105
checksum: Optional[str] = None
107106
size: Optional[int] = None
108107
"""Size in bytes of the uncompressed upload workspace."""

submit_ce/implementations/pubsub/tests/test_pubusb_impl.py renamed to submit_ce/implementations/pubsub/tests/test_pubsub_impl.py

File renamed without changes.

submit_ce/ui/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,22 @@ class _FakePdf:
298298
return submission
299299

300300

301+
@pytest.fixture(scope="function")
302+
def sub_files_tex(app, authorized_user, sub_files):
303+
"""sub_files with source_format set to TEX, so review_files runs its
304+
normal preflight/review flow rather than redirecting on the source_format
305+
guard."""
306+
with app.app_context():
307+
user = authorized_user
308+
ua = InternalClient(name=f"test_client_{__file__}")
309+
submission, _ = current_app.api.save(
310+
SetSourceFormat(creator=user, client=ua,
311+
source_format=SourceFormat.TEX.value),
312+
submission_id=sub_files.submission_id,
313+
)
314+
return submission
315+
316+
301317
@pytest.fixture(scope="function")
302318
def sub_reviewfiles(app, authorized_user, sub_files):
303319
"""A submission that has passed through the review-files stage."""

submit_ce/ui/controllers/new/process.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from submit_ce.domain.event.process import StartCompileSource
1212
from submit_ce.domain.exceptions import SaveError
13+
from submit_ce.domain.uploads import SourceFormat
1314
from submit_ce.api.file_store import SubmissionFileStore
1415
from submit_ce.ui import SUPPORT
1516

@@ -21,7 +22,9 @@
2122
from wtforms import SelectField
2223

2324
from ..util import validate_command
24-
from submit_ce.ui.routes.flow_control import ready_for_next, stay_on_this_stage
25+
from submit_ce.ui.routes.flow_control import (
26+
ready_for_next, stay_on_this_stage, advance_to_current,
27+
)
2528
from submit_ce.ui.backend import get_submission
2629

2730

@@ -60,6 +63,10 @@ def file_process(method: str, params: MultiDict, session: Session,
6063
applicable.
6164
6265
"""
66+
submission, _ = get_submission(submission_id)
67+
if submission.source_format == SourceFormat.PDF:
68+
return advance_to_current(({}, status.OK, {}))
69+
6370
if method == "GET":
6471
return compile_status(params, session, submission_id, token)
6572
elif method == "POST":
@@ -211,7 +218,7 @@ def start_compilation(params: MultiDict, session: Session, submission_id: str,
211218
# if 'reason' in result.extra and "produced from TeX source" in result.extra['reason']:
212219
# alerts.flash_failure(TEX_PRODUCED_MARKUP)
213220
# elif 'reason' in result.extra and 'docker' in result.extra['reason']:
214-
# alerts.flash_failure(DOCKER_ERROR_MARKUOP)
221+
# alerts.flash_failure(DOCKER_ERROR_MARKUP)
215222
# else:
216223
# alerts.flash_failure(f"Processing failed")
217224
# else:
@@ -262,7 +269,7 @@ class CompilationForm(csrf.CSRFForm):
262269
"submission is TeX produced is incorrect, you should send " \
263270
"e-mail with your submission ID to " \
264271
'<a href="mailto:help@arxiv.org">arXiv administrators.</a></p>')
265-
DOCKER_ERROR_MARKUOP = \
272+
DOCKER_ERROR_MARKUP = \
266273
Markup("Our automatic TeX processing system has failed to launch. " \
267274
"There is a good chance we are aware of the issue, but if the " \
268275
"problem persists you should send e-mail with your submission " \

submit_ce/ui/controllers/new/review.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from http import HTTPStatus as status
44
from typing import Tuple, Dict, Any, Optional, List
55

6+
import httpx
67
from flask import current_app
78
from arxiv.auth.domain import Session
89
from arxiv.base import alerts
@@ -24,10 +25,13 @@
2425
from wtforms import SelectField
2526
from wtforms.validators import DataRequired
2627

27-
from submit_ce.domain.uploads import Workspace
28+
from submit_ce.domain.uploads import Workspace, SourceFormat
2829
from submit_ce.domain.exceptions import InvalidEvent, SaveError
2930
from submit_ce.ui.controllers.util import validate_command
30-
from submit_ce.ui.routes.flow_control import stay_on_this_stage, ready_for_next, return_to_parent_stage
31+
from submit_ce.ui.routes.flow_control import (
32+
stay_on_this_stage, ready_for_next, return_to_parent_stage,
33+
return_to_previous_stage, advance_to_current,
34+
)
3135
from submit_ce.ui.backend import get_submission
3236
from submit_ce.ui import SUPPORT
3337

@@ -153,6 +157,12 @@ def review_files(method: str, params: MultiDict, session: Session,
153157
if not workspace:
154158
return return_to_parent_stage((rdata, status.OK, {}))
155159

160+
if submission.source_format == SourceFormat.PDF:
161+
return advance_to_current((rdata, status.OK, {}))
162+
163+
if submission.source_format != SourceFormat.TEX:
164+
return return_to_previous_stage((rdata, status.OK, {}))
165+
156166
if method == 'GET':
157167
preflight_data, user_decisions_data = _load_or_create_preflight(
158168
submission_id, params, session, token, workspace, submitter, client
@@ -418,3 +428,11 @@ def start_directives(params: MultiDict, session: Session, submission_id: str,
418428
except SaveError as e:
419429
alerts.flash_failure(f"We couldn't start directives. {SUPPORT}", title="Directives failed")
420430
raise InternalServerError(response_data) from e
431+
except httpx.HTTPError as e:
432+
logger.error('Compile service error during StartDirectives for %s: %s',
433+
submission_id, e)
434+
alerts.flash_failure(
435+
f"We couldn't start directives because the compile service"
436+
f" is unavailable. {SUPPORT}",
437+
title="Directives failed")
438+
raise InternalServerError(response_data) from e

submit_ce/ui/controllers/new/tests/test_review.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
from submit_ce.ui.controllers.new import review
1515

1616

17-
def test_review_files_get_warning_via_http(app, authorized_client, sub_files,
17+
def test_review_files_get_warning_via_http(app, authorized_client, sub_files_tex,
1818
mocker):
1919
"""End-to-end: GET /<id>/review_files triggers flash_warning when
2020
_load_or_create_preflight yields no preflight data."""
2121
mocker.patch.object(review, '_load_or_create_preflight',
2222
return_value=(None, None))
2323
mock_flash = mocker.patch.object(review.alerts, 'flash_warning')
2424

25-
url = f"/{sub_files.submission_id}/review_files"
25+
url = f"/{sub_files_tex.submission_id}/review_files"
2626
resp = authorized_client.get(url)
2727

2828
assert resp.status_code == status.OK
@@ -65,10 +65,10 @@ def _get_csrf(authorized_client, url, mocker):
6565

6666

6767
def test_review_files_post_with_changes_redirects_to_parent(
68-
app, authorized_client, sub_files, mocker):
68+
app, authorized_client, sub_files_tex, mocker):
6969
"""End-to-end POST: when _update_preflight reports changes, the controller
7070
marks STAGE_PARENT and the flow redirects (303 SEE_OTHER)."""
71-
url = f"/{sub_files.submission_id}/review_files"
71+
url = f"/{sub_files_tex.submission_id}/review_files"
7272
csrf = _get_csrf(authorized_client, url, mocker)
7373

7474
mock_update = mocker.patch.object(review, '_update_preflight',
@@ -83,10 +83,10 @@ def test_review_files_post_with_changes_redirects_to_parent(
8383

8484

8585
def test_review_files_post_no_changes_no_preflight_flashes(
86-
app, authorized_client, sub_files, mocker):
86+
app, authorized_client, sub_files_tex, mocker):
8787
"""End-to-end POST: when there are no changes but preflight is still
8888
unavailable, the controller flashes a warning and stays on the stage."""
89-
url = f"/{sub_files.submission_id}/review_files"
89+
url = f"/{sub_files_tex.submission_id}/review_files"
9090
csrf = _get_csrf(authorized_client, url, mocker)
9191

9292
mocker.patch.object(review, '_update_preflight', return_value=False)
@@ -105,10 +105,10 @@ def test_review_files_post_no_changes_no_preflight_flashes(
105105

106106

107107
def test_review_files_post_no_changes_stores_zzrm_and_advances(
108-
app, authorized_client, sub_files, mocker):
108+
app, authorized_client, sub_files_tex, mocker):
109109
"""End-to-end POST: when there are no changes and preflight is present,
110110
the controller stores the merged zzrm and advances to the next stage."""
111-
url = f"/{sub_files.submission_id}/review_files"
111+
url = f"/{sub_files_tex.submission_id}/review_files"
112112
csrf = _get_csrf(authorized_client, url, mocker)
113113

114114
mocker.patch.object(review, '_update_preflight', return_value=False)
@@ -131,7 +131,7 @@ def test_review_files_post_no_changes_stores_zzrm_and_advances(
131131
fake_zzrm.from_dict.assert_called_once_with({'sources': []})
132132
fake_zzrm.update_from_preflight.assert_called_once()
133133
mock_store.store_zzrm.assert_called_once_with(
134-
str(sub_files.submission_id), {'merged': True}
134+
str(sub_files_tex.submission_id), {'merged': True}
135135
)
136136

137137

submit_ce/ui/controllers/new/tests/test_upload.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def test_upload(app, authorized_client, sub_cross):
3232
b"<title>Upload" in resp.data \
3333
and b"<form " in resp.data
3434

35+
3536
class TestUpload(CtrlBase):
3637
"""Tests for :func:`submit_ce.controllers.upload`."""
3738

@@ -160,8 +161,8 @@ def test_post_upload(self):
160161
data, code, _ = upload.upload_files('POST', params, self.session,
161162
submission_id, files=files,
162163
token='footoken')
163-
self.assertEqual(mock_api.save.call_count, 1,
164-
'Saves the upload command via the api')
164+
self.assertEqual(mock_api.save.call_count, 2,
165+
'Saves UploadFiles and SetSourceFormat via the api')
165166
self.assertEqual(code, status.OK)
166167
self.assertEqual(get_controllers_desire(data), STAGE_RESHOW,
167168
'Successful upload and reshow form')
@@ -229,8 +230,10 @@ def test_post_delete_confirmed(self):
229230
self.session,
230231
submission_id,
231232
'footoken')
232-
self.assertEqual(mock_api.save.call_count, 1,
233-
'Saves the remove-files command via the api')
233+
self.assertEqual(mock_api.save.call_count, 2,
234+
'Saves RemoveFiles and SetSourceFormat via the api')
234235
self.assertEqual(code, status.OK)
235236
self.assertEqual(get_controllers_desire(data), STAGE_PARENT,
236237
'Confirmed delete returns to the parent stage')
238+
239+

0 commit comments

Comments
 (0)