quetz-server


Namequetz-server JSON
Version 0.10.4 PyPI version JSON
download
home_pagehttps://github.com/mamba-org/quetz
SummaryThe mamba-org server for conda packages
upload_time2023-12-04 14:35:06
maintainer
docs_urlNone
authorQuantStack & Quetz contributors
requires_python>=3.7
license
keywords conda mamba server
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![quetz header image](docs/assets/quetz_header.png)

## The Open-Source Server for Conda Packages

<table>
<thead align="center" cellspacing="10">
  <tr>
    <th colspan="3" align="center" border="">part of mamba-org</th>
  </tr>
</thead>
<tbody>
  <tr background="#FFF">
    <td align="center">Package Manager <a href="https://github.com/mamba-org/mamba">mamba</a></td>
    <td align="center">Package Server <a href="https://github.com/mamba-org/quetz">quetz</a></td>
    <td align="center">Package Builder <a href="https://github.com/mamba-org/boa">boa</a></td>
  </tr>
</tbody>
</table>

# Quetz

[![Documentation Status](https://readthedocs.org/projects/quetz/badge/?version=latest)](https://quetz.readthedocs.io/en/latest/?badge=latest)
[![Docker Version](https://img.shields.io/docker/v/mambaorg/quetz/latest?label=docker)](https://hub.docker.com/r/mambaorg/quetz/tags)

The quetz project is an open source server for conda packages.
It is built upon FastAPI with an API-first approach.
A quetz server can have many users, channels and packages.
With quetz, fine-grained permissions on channel and package-name level will be possible.

Quetz has an optional client [`quetz-client`](https://github.com/mamba-org/quetz-client) that can be used to upload packages to a quetz server instance.

## Usage

You should have [mamba](https://github.com/mamba-org/mamba) or conda installed.

Get `Quetz` sources:

```bash
git clone https://github.com/mamba-org/quetz.git
```

Then create an environment:

```bash
cd quetz
mamba env create -f environment.yml
conda activate quetz
ln -s "${CONDA_PREFIX}" .venv  # Necessary for pyright.
```

Install `Quetz`:

> Use the editable mode `-e` if you are developer and want to take advantage of the `reload` option of `Quetz`

```bash
pip install -e .
```

Use the CLI to create a `Quetz` instance:

```bash
quetz run test_quetz --copy-conf ./dev_config.toml --dev --reload
```

Links:

- <http://localhost:8000/> - Login with your github account
- <http://localhost:8000/api/dummylogin/alice> - Login with test user, one of [alice | bob | carol | dave]
- <http://localhost:8000/docs> - Swagger UI for this REST service

Download `xtensor` as test package:

```bash
./download-test-package.sh
```

To upload the package, install the [quetz-client](https://github.com/mamba-org/quetz-client):

```bash
mamba install quetz-client
```

To run the upload, you need to set environment variables for the quetz API key (which authenticates you) and the quetz server URL. As we passed the `--dev` flag to quetz, a testing API key can be found in quetz's output which you can use for this example.

```bash
export QUETZ_API_KEY=E_KaBFstCKI9hTdPM7DQq56GglRHf2HW7tQtq6si370
export QUETZ_SERVER_URL=http://localhost:8000
quetz-client post_file_to_channel channel0 xtensor/linux-64/xtensor-0.24.3-h924138e_1.tar.bz2
quetz-client post_file_to_channel channel0 xtensor/osx-64/xtensor-0.24.3-h1b54a9f_1.tar.bz2
quetz-client post_file_to_channel channel0 xtensor/osx-arm64/xtensor-0.24.3-hf86a087_1.tar.bz2
```

Install the test package with conda:

```bash
mamba install --strict-channel-priority -c http://localhost:8000/get/channel0 -c conda-forge xtensor
```

Output:

```text
...
  Package  Version  Build          Channel                                                     Size
─────────────────────────────────────────────────────────────────────────────────────────────────────
  Install:
─────────────────────────────────────────────────────────────────────────────────────────────────────

  xtensor   0.16.1  0              http://localhost:8000/get/channel0/osx-64                 109 KB
  xtl       0.4.16  h04f5b5a_1000  conda-forge/osx-64                                         47 KB

  Summary:

  Install: 2 packages

  Total download: 156 KB

─────────────────────────────────────────────────────────────────────────────────────────────────────
...
```

Browse channels: <http://localhost:8000/get/channel0/>

## S3 Backend

To enable the S3 backend, you will first require the s3fs library:

```bash
mamba install -c conda-forge s3fs
```

Then add your access and secret keys to the `s3` section with your
`config.toml`, like so:

```ini
[s3]
access_key = "AKIAIOSFODNN7EXAMPLE"
secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
url = "https://..."
region = ""
bucket_prefix="..."
bucket_suffix="..."
```

Be sure to set the url and region field if not using AWS.

Channels are created with the following semantics:

```text
{bucket_prefix}{channel_name}{bucket_suffix}
```

The s3 backend is currently designed for one bucket per channel. It may be possible to put all channels in one bucket, but that will require some code tweaks

If you're using IAM roles, don't set `access_key` and `secret_key` or set them to empty strings `""`.

## Google OAuth 2.0 OpenID Connect

To enable auth via Google, you will need to register an application at: <https://console.developers.google.com/apis/credentials>

Then add the client secret & ID to a `google` section of your `config.toml`:

```ini
[google]
client_id = "EXAMPLEID420127570681-6rbcgdj683l3odc3nqearn2dr3pnaisq.apps.googleusercontent.com"
client_secret = "EXAMPLESECRETmD-7UXVCMZV3C7b-kZ9yf70"
```

## PostgreSQL

By default, quetz will run with sqlite database, which works well for local tests and small local instances. However, if you plan to run quetz in production, we recommend to configure it with the PostgreSQL database. There are several options to install PostgreSQL server on your local machine or production server, one of them being the official PostgreSQL docker image.

### Running PostgreSQL server with docker

You can the PostgresSQL image from the docker hub and start the server with the commands:

```bash
docker pull postgres
docker run --name some-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres
```

This will start the server with the user `postgres` and the password `mysecretpassword` that will be listening for connection on the port 5432 of localhost.

You can then create a database in PostgreSQL for quetz tables:

```bash
sudo -u postgres psql -h localhost -c 'CREATE DATABASE quetz OWNER postgres;'
```

### Deploying Quetz with PostgreSQL backend

Then in your configuration file (such as `dev_config.toml`) replace the `[sqlalchemy]` section with:

```ini
[sqlalchemy]
database_url = "postgresql://postgres:mysecretpassword@localhost:5432/quetz"
```

Finally, you can create and run a new quetz deployment based on this configuration (we assume that you saved it in file `config_postgres.toml`):

```bash
quetz run postgres_quetz --copy-conf config_postgres.toml
```

Note that this recipe will create an ephemeral PostgreSQL database and it will delete all data after the `some-postgres` container is stopped and removed. To make the data persistent, please check the documentation of the `postgres` [image](https://hub.docker.com/_/postgres/) or your container orchestration system (Kubernetes or similar).

### Running tests with PostgreSQL backend

To run the tests with the PostgreSQL database instead of the default SQLite, follow the steps [above](#running-postgresql-server-with-docker) to start the PG server. Then create an new database:

```bash
psql -U postgres -h localhost -c 'CREATE DATABASE test_quetz OWNER postgres;'
```

You will be asked to type the password to the DB, which you defined when starting your PG server. In the docker-based instructions above, we set it to `mysecretpassword`.

To run the tests with this database you need to configure the `QUETZ_TEST_DATABASE` environment variable:

```bash
QUETZ_TEST_DATABASE="postgresql://postgres:mysecretpassword@localhost:5432/test_quetz" pytest -v ./quetz/tests
```

## Frontend

Quetz comes with a initial frontend implementation. It can be found in quetz_frontend.
To build it, one needs to install:

```bash
mamba install 'nodejs>=14'
cd quetz_frontend
npm install
npm run build
# for development
npm run watch
```

This will build the javascript files and place them in `/quetz_frontend/dist/` from where they are automatically picked up by the quetz server.

## Using quetz

### Create a channel

First, make sure you're logged in to the web app.

Then, using the swagger docs at `<deployment url>:<port>/docs`, POST to `/api/channels` with the name and description of your new channel:

```json
{
  "name": "my-channel",
  "description": "Description for my-channel",
  "private": false
}
```

This will create a new channel called `my-channel` and your user will be the Owner of that channel.

### Generate an API key

API keys are scoped per channel, per user and optionally per package.
In order to generate an API key the following must be true:

1. First, make sure you're logged in to the web app.
2. The user must be part of the target channel (you might need to create a channel first, see the previous section on how to create a channel via the swagger docs)
3. Go to the swagger docs at `<deployment url>:<port>/docs` and POST to `/api/api-keys`:

   ```json
   {
     "description": "my-test-token",
     "roles": [
       {
         "role": "owner",
         "channel": "my-channel"
       }
     ]
   }
   ```

4. Then, GET on `/api/api-keys` to retrieve your token
5. Finally, set the QUETZ_API_KEY environment variable to this value so you can use quetz-client to interact with the server.

### Create a proxy channel

A proxy channel "mirrors" another channel usually from a different server, so that the packages can be installed from the proxy as if they were installed directly from that server. All downloaded packages are cached locally and the cache is always up to date (there is no risk of serving stale packages). The reason to use the proxy channel is to limit traffic to the server of origin or to serve a channel that could be inaccessible from behind the corporate firewall.

To create a proxy channel use the properties `mirror_channel_url=URL_TO_SOURCE_CHANNEL` and `mirror_mode='proxy'` in the POST method of `/api/channels` endpoint. For example, to proxy the channel named `btel` from anaconda cloud server, you might use the following request data:

```json
{
  "name": "proxy-channel",
  "private": false,
  "mirror_channel_url": "https://conda.anaconda.org/btel",
  "mirror_mode": "proxy"
}
```

You may copy the data directly to the Swagger web interface under the heading POST `/api/channels` or use the cURL tool from command line. Assuming that you deployed a quetz server on port 8000 (the default) on your local machine, you could make the request with the following cURL command:

```bash
export QUETZ_API_KEY=...
curl -X POST "http://localhost:8000/api/channels" \
    -H  "accept: application/json" \
    -H  "Content-Type: application/json" \
    -H  "X-API-Key: ${QUETZ_API_KEY}" \
    -d '{"name":"proxy-channel",
         "private":false,
         "mirror_channel_url":"https://conda.anaconda.org/btel",
         "mirror_mode":"proxy"}'
```

where the value of `QUETZ_API_KEY` variable should be the API key that was printed when you created the quetz deployment or retrieved using the API as described in the section [Generate an API key](#generate-an-api-key).

Then you can install packages from the channel the standard way using `conda` or `mamba`:

```bash
mamba install --strict-channel-priority -c http://localhost:8000/get/proxy-channel nrnpython
```

### Create a mirroring channel

A mirror channel is an exact copy of another channel usually from a different (anaconda or quetz) server. The packages are downloaded from that server and added to the mirror channel. The mirror channel supports the standard Quetz API except requests that would add or modify the packages (POST `/api/channels/{name}/files`, for example). Mirror channels can be used to off load traffic from the primary server, or to create a channel clone on the company Intranet.

Creating a mirror channel is similar to creating proxy channels except that you need to change the value of `mirror_mode` attribute from `proxy` to `mirror` (and choose a more suitable channel name obviously):

```json
{
  "name": "mirror-channel",
  "private": false,
  "mirror_channel_url": "https://conda.anaconda.org/btel",
  "mirror_mode": "mirror"
}
```

or with cURL:

```bash
export QUETZ_API_KEY=...
curl -X POST "http://localhost:8000/api/channels" \
    -H  "accept: application/json" \
    -H  "Content-Type: application/json" \
    -H  "X-API-Key: ${QUETZ_API_KEY}" \
    -d '{"name":"mirror-channel",
         "private":false,
         "mirror_channel_url":"https://conda.anaconda.org/btel",
         "mirror_mode":"mirror"}'
```

Mirror channels are read only (you can not add or change packages in these channels), but otherwise they are fully functional Quetz channels and support all standard read (GET) operations. For example, you may list all packages using GET `/api/channels/{channel_name}/packages` endpoint:

```bash
curl http://localhost:8000/api/channels/mirror-channel/packages
```

If packages are added or modified on the primary server from which they were pulled initially, they won't be updated automatically in the mirror channel. However, you can trigger such synchronisation manually using the PUT `/api/channels/{channel_name}/actions` endpoint:

```bash
curl -X PUT localhost:8000/api/channels/mirror-channel/actions \
   -H "X-API-Key: ${QUETZ_API_KEY}" \
   -d '{"action": "synchronize"}'
```

Only channel owners or maintainers are allowed to trigger synchronisation, therefore you have to provide a valid API key of a privileged user.

## Plugins

Quetz offers plugins in the plugins folder of this repo as well as via standalone installs. The following plugins are currently available:

| Plugin                                                                          | Description                                                                                                                |
| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| [quetz_conda_suggest](plugins/quetz_conda_suggest/)                             | Generate `.map` files for [conda-suggest](https://github.com/conda-incubator/conda-suggest)                                |
| [quetz_content_trust](plugins/quetz_content_trust/)                             | Generate signed repodata files                                                                                             |
| [quetz_current_repodata](plugins/quetz_current_repodata/)                       | Trim the repodata to only include latest package versions                                                                  |
| [quetz_dictauthenticator](plugins/quetz_dictauthenticator/)                     | Demo for creating new authenticators                                                                                       |
| [quetz_harvester](plugins/quetz_harvester/)                                     | Extract additional metadata from packages using the [libcflib](https://github.com/regro/libcflib) harvester                |
| [quetz_mamba_solve](plugins/quetz_mamba_solve/)                                 | Export a specific set of package versions for reproducibility                                                              |
| [quetz_repodata_patching](plugins/quetz_repodata_patching/)                     | [Repodata patching](https://docs.conda.io/projects/conda-build/en/latest/concepts/generating-index.html#repodata-patching) |
| [quetz_repodata_zchunk](plugins/quetz_repodata_zchunk/)                         | Serve repodata using [zchunk](https://github.com/zchunk/zchunk)                                                            |
| [quetz_runexports](plugins/quetz_runexports/)                                   | Extract and expose `run_exports` from package files                                                                        |
| [quetz_sql_authenticator](https://github.com/mamba-org/quetz-sql-authenticator) | An authenticator that stores credentials in the Quetz SQL database using passlib.                                          |
| [quetz_tos](plugins/quetz_tos/)                                                 | Enforce signing the terms of service for Quetz users                                                                       |
| [quetz_transmutation](plugins/quetz_transmutation/)                             | Convert packages to .conda format                                                                                          |

## License

We use a shared copyright model that enables all contributors to maintain the copyright on their contributions.

This software is licensed under the BSD-3-Clause license. See the [LICENSE](LICENSE) file for details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mamba-org/quetz",
    "name": "quetz-server",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "conda,mamba,server",
    "author": "QuantStack & Quetz contributors",
    "author_email": "wolf.vollprecht@quantstack.net",
    "download_url": "https://files.pythonhosted.org/packages/c1/b9/dff0a48765c7911e564df75393a1224bc3f5fb776ba612eff9a24db4dc84/quetz-server-0.10.4.tar.gz",
    "platform": "Linux",
    "description": "![quetz header image](docs/assets/quetz_header.png)\n\n## The Open-Source Server for Conda Packages\n\n<table>\n<thead align=\"center\" cellspacing=\"10\">\n  <tr>\n    <th colspan=\"3\" align=\"center\" border=\"\">part of mamba-org</th>\n  </tr>\n</thead>\n<tbody>\n  <tr background=\"#FFF\">\n    <td align=\"center\">Package Manager <a href=\"https://github.com/mamba-org/mamba\">mamba</a></td>\n    <td align=\"center\">Package Server <a href=\"https://github.com/mamba-org/quetz\">quetz</a></td>\n    <td align=\"center\">Package Builder <a href=\"https://github.com/mamba-org/boa\">boa</a></td>\n  </tr>\n</tbody>\n</table>\n\n# Quetz\n\n[![Documentation Status](https://readthedocs.org/projects/quetz/badge/?version=latest)](https://quetz.readthedocs.io/en/latest/?badge=latest)\n[![Docker Version](https://img.shields.io/docker/v/mambaorg/quetz/latest?label=docker)](https://hub.docker.com/r/mambaorg/quetz/tags)\n\nThe quetz project is an open source server for conda packages.\nIt is built upon FastAPI with an API-first approach.\nA quetz server can have many users, channels and packages.\nWith quetz, fine-grained permissions on channel and package-name level will be possible.\n\nQuetz has an optional client [`quetz-client`](https://github.com/mamba-org/quetz-client) that can be used to upload packages to a quetz server instance.\n\n## Usage\n\nYou should have [mamba](https://github.com/mamba-org/mamba) or conda installed.\n\nGet `Quetz` sources:\n\n```bash\ngit clone https://github.com/mamba-org/quetz.git\n```\n\nThen create an environment:\n\n```bash\ncd quetz\nmamba env create -f environment.yml\nconda activate quetz\nln -s \"${CONDA_PREFIX}\" .venv  # Necessary for pyright.\n```\n\nInstall `Quetz`:\n\n> Use the editable mode `-e` if you are developer and want to take advantage of the `reload` option of `Quetz`\n\n```bash\npip install -e .\n```\n\nUse the CLI to create a `Quetz` instance:\n\n```bash\nquetz run test_quetz --copy-conf ./dev_config.toml --dev --reload\n```\n\nLinks:\n\n- <http://localhost:8000/> - Login with your github account\n- <http://localhost:8000/api/dummylogin/alice> - Login with test user, one of [alice | bob | carol | dave]\n- <http://localhost:8000/docs> - Swagger UI for this REST service\n\nDownload `xtensor` as test package:\n\n```bash\n./download-test-package.sh\n```\n\nTo upload the package, install the [quetz-client](https://github.com/mamba-org/quetz-client):\n\n```bash\nmamba install quetz-client\n```\n\nTo run the upload, you need to set environment variables for the quetz API key (which authenticates you) and the quetz server URL. As we passed the `--dev` flag to quetz, a testing API key can be found in quetz's output which you can use for this example.\n\n```bash\nexport QUETZ_API_KEY=E_KaBFstCKI9hTdPM7DQq56GglRHf2HW7tQtq6si370\nexport QUETZ_SERVER_URL=http://localhost:8000\nquetz-client post_file_to_channel channel0 xtensor/linux-64/xtensor-0.24.3-h924138e_1.tar.bz2\nquetz-client post_file_to_channel channel0 xtensor/osx-64/xtensor-0.24.3-h1b54a9f_1.tar.bz2\nquetz-client post_file_to_channel channel0 xtensor/osx-arm64/xtensor-0.24.3-hf86a087_1.tar.bz2\n```\n\nInstall the test package with conda:\n\n```bash\nmamba install --strict-channel-priority -c http://localhost:8000/get/channel0 -c conda-forge xtensor\n```\n\nOutput:\n\n```text\n...\n  Package  Version  Build          Channel                                                     Size\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n  Install:\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n  xtensor   0.16.1  0              http://localhost:8000/get/channel0/osx-64                 109 KB\n  xtl       0.4.16  h04f5b5a_1000  conda-forge/osx-64                                         47 KB\n\n  Summary:\n\n  Install: 2 packages\n\n  Total download: 156 KB\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n...\n```\n\nBrowse channels: <http://localhost:8000/get/channel0/>\n\n## S3 Backend\n\nTo enable the S3 backend, you will first require the s3fs library:\n\n```bash\nmamba install -c conda-forge s3fs\n```\n\nThen add your access and secret keys to the `s3` section with your\n`config.toml`, like so:\n\n```ini\n[s3]\naccess_key = \"AKIAIOSFODNN7EXAMPLE\"\nsecret_key = \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\"\nurl = \"https://...\"\nregion = \"\"\nbucket_prefix=\"...\"\nbucket_suffix=\"...\"\n```\n\nBe sure to set the url and region field if not using AWS.\n\nChannels are created with the following semantics:\n\n```text\n{bucket_prefix}{channel_name}{bucket_suffix}\n```\n\nThe s3 backend is currently designed for one bucket per channel. It may be possible to put all channels in one bucket, but that will require some code tweaks\n\nIf you're using IAM roles, don't set `access_key` and `secret_key` or set them to empty strings `\"\"`.\n\n## Google OAuth 2.0 OpenID Connect\n\nTo enable auth via Google, you will need to register an application at: <https://console.developers.google.com/apis/credentials>\n\nThen add the client secret & ID to a `google` section of your `config.toml`:\n\n```ini\n[google]\nclient_id = \"EXAMPLEID420127570681-6rbcgdj683l3odc3nqearn2dr3pnaisq.apps.googleusercontent.com\"\nclient_secret = \"EXAMPLESECRETmD-7UXVCMZV3C7b-kZ9yf70\"\n```\n\n## PostgreSQL\n\nBy default, quetz will run with sqlite database, which works well for local tests and small local instances. However, if you plan to run quetz in production, we recommend to configure it with the PostgreSQL database. There are several options to install PostgreSQL server on your local machine or production server, one of them being the official PostgreSQL docker image.\n\n### Running PostgreSQL server with docker\n\nYou can the PostgresSQL image from the docker hub and start the server with the commands:\n\n```bash\ndocker pull postgres\ndocker run --name some-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres\n```\n\nThis will start the server with the user `postgres` and the password `mysecretpassword` that will be listening for connection on the port 5432 of localhost.\n\nYou can then create a database in PostgreSQL for quetz tables:\n\n```bash\nsudo -u postgres psql -h localhost -c 'CREATE DATABASE quetz OWNER postgres;'\n```\n\n### Deploying Quetz with PostgreSQL backend\n\nThen in your configuration file (such as `dev_config.toml`) replace the `[sqlalchemy]` section with:\n\n```ini\n[sqlalchemy]\ndatabase_url = \"postgresql://postgres:mysecretpassword@localhost:5432/quetz\"\n```\n\nFinally, you can create and run a new quetz deployment based on this configuration (we assume that you saved it in file `config_postgres.toml`):\n\n```bash\nquetz run postgres_quetz --copy-conf config_postgres.toml\n```\n\nNote that this recipe will create an ephemeral PostgreSQL database and it will delete all data after the `some-postgres` container is stopped and removed. To make the data persistent, please check the documentation of the `postgres` [image](https://hub.docker.com/_/postgres/) or your container orchestration system (Kubernetes or similar).\n\n### Running tests with PostgreSQL backend\n\nTo run the tests with the PostgreSQL database instead of the default SQLite, follow the steps [above](#running-postgresql-server-with-docker) to start the PG server. Then create an new database:\n\n```bash\npsql -U postgres -h localhost -c 'CREATE DATABASE test_quetz OWNER postgres;'\n```\n\nYou will be asked to type the password to the DB, which you defined when starting your PG server. In the docker-based instructions above, we set it to `mysecretpassword`.\n\nTo run the tests with this database you need to configure the `QUETZ_TEST_DATABASE` environment variable:\n\n```bash\nQUETZ_TEST_DATABASE=\"postgresql://postgres:mysecretpassword@localhost:5432/test_quetz\" pytest -v ./quetz/tests\n```\n\n## Frontend\n\nQuetz comes with a initial frontend implementation. It can be found in quetz_frontend.\nTo build it, one needs to install:\n\n```bash\nmamba install 'nodejs>=14'\ncd quetz_frontend\nnpm install\nnpm run build\n# for development\nnpm run watch\n```\n\nThis will build the javascript files and place them in `/quetz_frontend/dist/` from where they are automatically picked up by the quetz server.\n\n## Using quetz\n\n### Create a channel\n\nFirst, make sure you're logged in to the web app.\n\nThen, using the swagger docs at `<deployment url>:<port>/docs`, POST to `/api/channels` with the name and description of your new channel:\n\n```json\n{\n  \"name\": \"my-channel\",\n  \"description\": \"Description for my-channel\",\n  \"private\": false\n}\n```\n\nThis will create a new channel called `my-channel` and your user will be the Owner of that channel.\n\n### Generate an API key\n\nAPI keys are scoped per channel, per user and optionally per package.\nIn order to generate an API key the following must be true:\n\n1. First, make sure you're logged in to the web app.\n2. The user must be part of the target channel (you might need to create a channel first, see the previous section on how to create a channel via the swagger docs)\n3. Go to the swagger docs at `<deployment url>:<port>/docs` and POST to `/api/api-keys`:\n\n   ```json\n   {\n     \"description\": \"my-test-token\",\n     \"roles\": [\n       {\n         \"role\": \"owner\",\n         \"channel\": \"my-channel\"\n       }\n     ]\n   }\n   ```\n\n4. Then, GET on `/api/api-keys` to retrieve your token\n5. Finally, set the QUETZ_API_KEY environment variable to this value so you can use quetz-client to interact with the server.\n\n### Create a proxy channel\n\nA proxy channel \"mirrors\" another channel usually from a different server, so that the packages can be installed from the proxy as if they were installed directly from that server. All downloaded packages are cached locally and the cache is always up to date (there is no risk of serving stale packages). The reason to use the proxy channel is to limit traffic to the server of origin or to serve a channel that could be inaccessible from behind the corporate firewall.\n\nTo create a proxy channel use the properties `mirror_channel_url=URL_TO_SOURCE_CHANNEL` and `mirror_mode='proxy'` in the POST method of `/api/channels` endpoint. For example, to proxy the channel named `btel` from anaconda cloud server, you might use the following request data:\n\n```json\n{\n  \"name\": \"proxy-channel\",\n  \"private\": false,\n  \"mirror_channel_url\": \"https://conda.anaconda.org/btel\",\n  \"mirror_mode\": \"proxy\"\n}\n```\n\nYou may copy the data directly to the Swagger web interface under the heading POST `/api/channels` or use the cURL tool from command line. Assuming that you deployed a quetz server on port 8000 (the default) on your local machine, you could make the request with the following cURL command:\n\n```bash\nexport QUETZ_API_KEY=...\ncurl -X POST \"http://localhost:8000/api/channels\" \\\n    -H  \"accept: application/json\" \\\n    -H  \"Content-Type: application/json\" \\\n    -H  \"X-API-Key: ${QUETZ_API_KEY}\" \\\n    -d '{\"name\":\"proxy-channel\",\n         \"private\":false,\n         \"mirror_channel_url\":\"https://conda.anaconda.org/btel\",\n         \"mirror_mode\":\"proxy\"}'\n```\n\nwhere the value of `QUETZ_API_KEY` variable should be the API key that was printed when you created the quetz deployment or retrieved using the API as described in the section [Generate an API key](#generate-an-api-key).\n\nThen you can install packages from the channel the standard way using `conda` or `mamba`:\n\n```bash\nmamba install --strict-channel-priority -c http://localhost:8000/get/proxy-channel nrnpython\n```\n\n### Create a mirroring channel\n\nA mirror channel is an exact copy of another channel usually from a different (anaconda or quetz) server. The packages are downloaded from that server and added to the mirror channel. The mirror channel supports the standard Quetz API except requests that would add or modify the packages (POST `/api/channels/{name}/files`, for example). Mirror channels can be used to off load traffic from the primary server, or to create a channel clone on the company Intranet.\n\nCreating a mirror channel is similar to creating proxy channels except that you need to change the value of `mirror_mode` attribute from `proxy` to `mirror` (and choose a more suitable channel name obviously):\n\n```json\n{\n  \"name\": \"mirror-channel\",\n  \"private\": false,\n  \"mirror_channel_url\": \"https://conda.anaconda.org/btel\",\n  \"mirror_mode\": \"mirror\"\n}\n```\n\nor with cURL:\n\n```bash\nexport QUETZ_API_KEY=...\ncurl -X POST \"http://localhost:8000/api/channels\" \\\n    -H  \"accept: application/json\" \\\n    -H  \"Content-Type: application/json\" \\\n    -H  \"X-API-Key: ${QUETZ_API_KEY}\" \\\n    -d '{\"name\":\"mirror-channel\",\n         \"private\":false,\n         \"mirror_channel_url\":\"https://conda.anaconda.org/btel\",\n         \"mirror_mode\":\"mirror\"}'\n```\n\nMirror channels are read only (you can not add or change packages in these channels), but otherwise they are fully functional Quetz channels and support all standard read (GET) operations. For example, you may list all packages using GET `/api/channels/{channel_name}/packages` endpoint:\n\n```bash\ncurl http://localhost:8000/api/channels/mirror-channel/packages\n```\n\nIf packages are added or modified on the primary server from which they were pulled initially, they won't be updated automatically in the mirror channel. However, you can trigger such synchronisation manually using the PUT `/api/channels/{channel_name}/actions` endpoint:\n\n```bash\ncurl -X PUT localhost:8000/api/channels/mirror-channel/actions \\\n   -H \"X-API-Key: ${QUETZ_API_KEY}\" \\\n   -d '{\"action\": \"synchronize\"}'\n```\n\nOnly channel owners or maintainers are allowed to trigger synchronisation, therefore you have to provide a valid API key of a privileged user.\n\n## Plugins\n\nQuetz offers plugins in the plugins folder of this repo as well as via standalone installs. The following plugins are currently available:\n\n| Plugin                                                                          | Description                                                                                                                |\n| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |\n| [quetz_conda_suggest](plugins/quetz_conda_suggest/)                             | Generate `.map` files for [conda-suggest](https://github.com/conda-incubator/conda-suggest)                                |\n| [quetz_content_trust](plugins/quetz_content_trust/)                             | Generate signed repodata files                                                                                             |\n| [quetz_current_repodata](plugins/quetz_current_repodata/)                       | Trim the repodata to only include latest package versions                                                                  |\n| [quetz_dictauthenticator](plugins/quetz_dictauthenticator/)                     | Demo for creating new authenticators                                                                                       |\n| [quetz_harvester](plugins/quetz_harvester/)                                     | Extract additional metadata from packages using the [libcflib](https://github.com/regro/libcflib) harvester                |\n| [quetz_mamba_solve](plugins/quetz_mamba_solve/)                                 | Export a specific set of package versions for reproducibility                                                              |\n| [quetz_repodata_patching](plugins/quetz_repodata_patching/)                     | [Repodata patching](https://docs.conda.io/projects/conda-build/en/latest/concepts/generating-index.html#repodata-patching) |\n| [quetz_repodata_zchunk](plugins/quetz_repodata_zchunk/)                         | Serve repodata using [zchunk](https://github.com/zchunk/zchunk)                                                            |\n| [quetz_runexports](plugins/quetz_runexports/)                                   | Extract and expose `run_exports` from package files                                                                        |\n| [quetz_sql_authenticator](https://github.com/mamba-org/quetz-sql-authenticator) | An authenticator that stores credentials in the Quetz SQL database using passlib.                                          |\n| [quetz_tos](plugins/quetz_tos/)                                                 | Enforce signing the terms of service for Quetz users                                                                       |\n| [quetz_transmutation](plugins/quetz_transmutation/)                             | Convert packages to .conda format                                                                                          |\n\n## License\n\nWe use a shared copyright model that enables all contributors to maintain the copyright on their contributions.\n\nThis software is licensed under the BSD-3-Clause license. See the [LICENSE](LICENSE) file for details.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "The mamba-org server for conda packages",
    "version": "0.10.4",
    "project_urls": {
        "Homepage": "https://github.com/mamba-org/quetz"
    },
    "split_keywords": [
        "conda",
        "mamba",
        "server"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7306ff66568df7c81efe509bd0d9d0c36c29efeb7c65b04c58705d6ebe61040d",
                "md5": "97f525d0d903c22d44d74c90cf5b1bf0",
                "sha256": "e286572a8f0311f48c7c5da40b9dc284dae4cf7a80175795d17d4ea35b904c3d"
            },
            "downloads": -1,
            "filename": "quetz_server-0.10.4-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "97f525d0d903c22d44d74c90cf5b1bf0",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 226147,
            "upload_time": "2023-12-04T14:35:09",
            "upload_time_iso_8601": "2023-12-04T14:35:09.261153Z",
            "url": "https://files.pythonhosted.org/packages/73/06/ff66568df7c81efe509bd0d9d0c36c29efeb7c65b04c58705d6ebe61040d/quetz_server-0.10.4-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c1b9dff0a48765c7911e564df75393a1224bc3f5fb776ba612eff9a24db4dc84",
                "md5": "9e018227163861f664c79c1daaa505ed",
                "sha256": "fde82b72b2e3fb22bfd0f6fec99ef41d845a76341801955e1d280be204049b90"
            },
            "downloads": -1,
            "filename": "quetz-server-0.10.4.tar.gz",
            "has_sig": false,
            "md5_digest": "9e018227163861f664c79c1daaa505ed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 310773,
            "upload_time": "2023-12-04T14:35:06",
            "upload_time_iso_8601": "2023-12-04T14:35:06.252237Z",
            "url": "https://files.pythonhosted.org/packages/c1/b9/dff0a48765c7911e564df75393a1224bc3f5fb776ba612eff9a24db4dc84/quetz-server-0.10.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-04 14:35:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mamba-org",
    "github_project": "quetz",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "quetz-server"
}
        
Elapsed time: 0.22168s