Skip to content

Commit 847b2bd

Browse files
committed
address general content feedback from review
1 parent c053242 commit 847b2bd

1 file changed

Lines changed: 31 additions & 21 deletions

File tree

peps/pep-0694.rst

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@ Post-History: `27-Jun-2022 <https://discuss.python.org/t/pep-694-upload-2-0-api-
1414
Abstract
1515
========
1616

17-
This PEP proposes a standard API for uploading files to a Python package index such as PyPI. Along
18-
with standardization, the upload API provides additional useful features such as support for:
17+
This PEP proposes an extensible API for uploading files to a Python package index such as PyPI.
18+
Along with standardization, the upload API provides additional useful features such as support for:
1919

2020
* an upload session, which can be used to simultaneously publish all wheels in a package release;
2121

22-
* "staging" a release, which can be used to test uploads before publicly publishing them, without the
23-
need for `test.pypi.org <https://test.pypi.org/>`__;
22+
* "staging" a release, which can be used to test uploads before publicly publishing them,
23+
without the need for `test.pypi.org <https://test.pypi.org/>`__;
2424

2525
* artifacts which can be overwritten and replaced, until a session is published;
2626

27-
* flexible file upload mechanisms for index operators;
28-
2927
* detailed status on the state of artifact uploads;
3028

3129
* new project creation without requiring the uploading of an artifact.
3230

31+
* a protocol to extend the supported upload mechanisms in the future without requiring a full PEP;
32+
these can be standardized and recommended for all indexes, or be index-specific;
33+
3334
Once this new upload API is adopted, the existing legacy API can be deprecated, however this PEP
3435
does not propose a deprecation schedule for the legacy API.
3536

@@ -77,11 +78,12 @@ In addition, there are a number of major issues with the legacy API:
7778
* Creation of new projects requires the uploading of at least one file, leading to "stub" uploads
7879
to claim a project namespace.
7980

80-
The new upload API proposed in this PEP provides a solution to all of these problems,
81-
providing for a much more flexible approach, with support for servers to
82-
implement resumable and parallel uploads via mechanisms,
83-
better error reporting, better release testing experience,
81+
The new upload API proposed in this PEP provides an immediate solution to many of these problems,
82+
and defines a flexible mechanism for future support of the other problems by extension.
83+
Indexes implementing this API will provide better error reporting,
84+
better release testing experience,
8485
and atomic and simultaneous publishing of all release artifacts.
86+
In the future indexes can implement resumable and parallel uploads via extensions.
8587

8688

8789
Legacy API
@@ -154,8 +156,9 @@ these steps:
154156

155157
#. Initiate an upload session, creating a release stage.
156158
#. Initiate file-upload session(s) to that stage as part of the upload session.
157-
#. Execute file upload mechanism for the file-upload session(s).
158-
#. Complete the file-upload session(s), marking them as executed or canceled.
159+
#. Negotiate the specific file upload mechanism to use between client and server.
160+
#. Execute file upload mechanism for the file-upload session(s) using the negotiated mechanism.
161+
#. Complete the file-upload session(s), marking them as completed or canceled.
159162
#. Complete the upload session, publishing or discarding the stage.
160163
#. Optionally check the status of an upload session.
161164

@@ -178,6 +181,8 @@ All URLs described here are relative to the "root endpoint", which may be locate
178181
the url structure of a domain. For example, the root endpoint could be
179182
``https://upload.example.com/``, or ``https://example.com/upload/``.
180183

184+
The choice of the root endpoint is left up to the index operator.
185+
181186
.. _session-create:
182187

183188
Create an Upload Session
@@ -271,7 +276,8 @@ the following keys:
271276
which are provided below.
272277

273278
``mechanisms``
274-
A list of file-upload mechanisms supported by the server.
279+
A list of file-upload mechanisms supported by the server, sorted in server-preferred order.
280+
At least one value is required.
275281

276282
``session-token``
277283
If the index supports :ref:`previewing staged releases <staged-preview>`, this key will contain
@@ -427,8 +433,7 @@ the file to be uploaded. These checks may include, but are not limited to:
427433
If the server determines that upload should proceed, it will return a ``202 Accepted`` response, with
428434
the response body below. The :ref:`status <session-status>` of the session will also include the filename in the ``files`` mapping. If the server determines the upload cannot proceed, it **MUST** return
429435
a ``409 Conflict``. The server **MAY** allow parallel uploads of files, but is not required to.
430-
If the server cannot proceed with an upload because the ``mechanism`` supplied by the client is not supported
431-
it **MUST** return a ``422 Unprocessable Entity``.
436+
If the server cannot proceed with an upload because the ``mechanism`` supplied by the client is not supported it **MUST** return a ``422 Unprocessable Entity``.
432437

433438
.. _file-upload-session-response:
434439

@@ -511,13 +516,18 @@ The requests looks like:
511516
"action": "complete",
512517
}
513518
519+
After receiving this requests the server **MAY** perform additional asynchronous processing
520+
on the file, for instance to verify its hashes or contents.
514521

515-
After receiving this requests the server **MAY** perform additional asynchronous processing on the file,
516-
for instance to verify its hashes or contents.
517-
If the processing is required to complete before an upload session can be published,
518-
the status of the file upload session can be set to ``processing`` until such processing is complete,
519-
reaches an error state, or the file upload session is canceled.
522+
If the file upload session requires no further processing, the server **MUST** respond with a
523+
``200 OK`` and the status of the file upload session **MUST** be set to set to ``complete``.
520524

525+
If such processing is required to complete before an upload session can be published,
526+
the server **MUST** respond with a ``202 Accepted`` and the status
527+
of the file upload session **MUST** be set to ``processing`` until such processing is complete,
528+
reaches an error state, or the file upload session is canceled.
529+
Clients can query the file upload session :ref:`status <session-status>` by issuing a GET request to
530+
the ``file-upload-session`` :ref:`link <file-upload-session-links>`.
521531

522532
.. _file-upload-session-cancelation:
523533

@@ -760,7 +770,7 @@ interpretation to aid in diagnosing underlying issue.
760770
File Upload Mechanisms
761771
----------------------
762772

763-
Servers **MUST** implement :ref:`required file upload mechansisms <required-file-upload-mechanisms>`.
773+
Servers **MUST** implement :ref:`required file upload mechanisms <required-file-upload-mechanisms>`.
764774
Such mechanisms serve as a fallback if no server specific implementations exist.
765775

766776
Each major version of the Upload API **MUST** specify at least one required File Upload Mechanism.

0 commit comments

Comments
 (0)