semvec/pypi-packages huggingface dataset:
leadergpu-python 0.1.3
Python SDK for LeaderGPU Public API
Requires Python: >=3.6

# Unofficial LeaderGPU Python SDK

A Python library for interacting with the LeaderGPU Public API

### Getting Started

1. Install with pip:

pip install leadergpu-python

2. Set the `LEADERGPU_CLIENT_ID` (email) and `LEADERGPU_AUTH_TOKEN` (password) environment variable:

```bash
export LEADERGPU_CLIENT_ID="username@mail.org"
export LEADERGPU_AUTH_TOKEN="XXXXXX"
```

3. Example for orderung a server:

```python
import os
from leadergpu import LeaderGPUClient

CLIENT_ID = os.environ['LEADERGPU_CLIENT_ID']
CLIENT_SECRET = os.environ['LEADERGPU_AUTH_TOKEN']

leadergpu = LeaderGPUClient(CLIENT_ID, CLIENT_SECRET)

# Get all products
products = leadergpu.products.get()

# Filter out products that are available
free_products = [product for product in products if product.free_time == None]
# Sort products by price and get the product with the lowest price
free_product = sorted(free_products, key=lambda product: product.price)

# Print the available sorted by the lowest price
for product in free_product:
    print(product)

# Order a the selected server, change the parameters accordingly example:
# product_id = 909
# os = 'ubuntu'
# period_count = 300
# Note the total cost has to be > 10 Euros, for a successful transaction
leadergpu.servers.order(product_id, os, period_count)
```
### Examples

Checkout the `/examples` directory for more examples on how to use the Python SDK.
requests-jwtauth 1.0.1
Authenticator plugins for Requests that support JWT bearer tokens
Requires Python: >=3.8

# requests-jwtauth

Authenticator plugins for [Requests] that support JWT bearer tokens.

## Description

This package contains two classes, `HTTPBearerAuth` and `JWTSecretAuth`,
that implement the [AuthBase] interface from the [Requests] package. The
`HTTPBearerAuth` class takes a single bearer token value at initialization,
and adds that to an `Authorization: Bearer` header. The
`JWTSecretAuth` class takes a shared secret, and uses that to generate and
sign short-lived [JWT] tokens to be added to an `Authorization: Bearer`
request header. By default, these tokens are valid for 1 hour (3600
seconds), and may contain arbitrary [JWT claims] in their payload.

## Dependencies

* Python 3.8+
* [Requests]
* [JWCrypto]

## Installation

```bash
pip install requests-jwtauth
```

## Usage

### HTTPBearerAuth

```python
import requests
from requests_jwtauth import HTTPBearerAuth

# send a request with a pre-obtained bearer token
my_token = '...'
r = requests.get('http://example.com', auth=HTTPBearerAuth(my_token))
```

### JWTSecretAuth

```python
import requests
from requests_jwtauth import JWTSecretAuth

# use a shared secret to generate (and automatically regenerate)
# short-lived JWT bearer tokens

secret_auth = JWTSecretAuth(
    # shared secret with the service that requires authentication
    secret='...',
    # JWT claims to place in the token payload
    # this class takes care of providing the 'exp' (expiration time) key
    claims={
        'sub': '...'
    },
    # Time-To-Live, in seconds; default is 3600 (i.e., 1 hour)
    ttl=3600,
    # instead of waiting for it to actually expire,
    # renew the token whenever the remaining time-to-live is
    # less than this number of seconds; default is 60
    expiration_buffer=60,
    # signing algorithm to use; defaults to H256
    signing_algorithm='H256'
)

r = requests.get('http://example.com', auth=secret_auth)
```

## Development Setup

```bash
git clone git@github.com:umd-lib/requests-jwtauth.git
cd requests-jwtauth
pyenv install $(cat .python-version) --skip-existing
python -m venv .venv --prompt "requests-jwtauth-py$(cat .python-version)"
source .venv/bin/activate
pip install -e .[test]
```

### Testing

Using [pytest]:

```bash
pytest
```

With [test coverage] information:

```bash
pytest --cov-report=term-missing --cov src
```

[Requests]: https://pypi.org/project/requests/
[AuthBase]: https://docs.python-requests.org/en/latest/user/authentication/#new-forms-of-authentication
[JWCrypto]: https://pypi.org/project/jwcrypto/
[JWT]: https://datatracker.ietf.org/doc/html/rfc7519
[JWT claims]: https://datatracker.ietf.org/doc/html/rfc7519#section-4
[pytest]: https://docs.pytest.org/en/latest/
[test coverage]: https://pytest-cov.readthedocs.io/en/latest/
swarmnet 0.0.8
A gossip-based swarm communication library
Requires Python: >=3.10

# SwarmNet

A robust communications library for robot swarms. This is based on gossip protocols where the message will propagate around the swarm. When an agent receives a message it has not seen before, it will broadcast it to all other members of the swarm. 

## Usage

A `SwarmNet` object must be created that handles all of the communication. Only one instance should be created. To start the communication framework, the `start()` method must be run.

**All devices must use the same port number**

This `start()` command will broadcast a JOIN command to register with the rest of the swarm. 

## Message Parsers

Parsers are defined to handle incoming messages of specific types, for example, you may want to send `COUNT 1` to increase a distributed counter by 1 when the `COUNT` command is received. This would be defined as follows.

```python

counter = 0

def count_recv(msg: Optional[str]) -> None:
  counter += int(msg)

sn = SwarmNet({"COUNT": count_recv})
sn.start()

while(True):
  pass

sn.kill()

```

*It is important to remember that the parser functions are called from a different thread. Special care should be taken to ensure data integrity and consistency across threads.*

The type of each parser is `Optional[str] -> None` where the string is a string of any fields in the message. For example, if the message is `CMD field1 field2`, the string will be `"field1 field2`.

If a message is received with a command token for which there is no parser, an error message is produced with a list of recognised command tokens. To prevent error spam in more complex systems, you can set certain commands to be ignored by defining the parser as `None`. For example, if the above code was deployed in a swarm that also had `DEBUG` messages that were only important to one specific node, you could ignore them using `None`.

```python

counter = 0

def count_recv(msg: Optional[str]) -> None:
  counter += int(msg)

sn = SwarmNet({"COUNT": count_recv, "DEBUG": None})
sn.start()

while(True):
  pass

sn.kill()

```

## Message Format

All messages follow the format: `<CMD> <DATA1> <DATA2> ...`

A dictionary that maps command tokens to functions is passed to the `SwarmNet` constructor. The signature of this map is `Dict[str, Optional[Callable[[Optional[str]], None]]]` where the `str` passed to the parser function is the rest of the message string (if any)

Internally, every message is prefixed with an identifier that is not overwritten when the message is forwarded by receivers. This means agents will not parse their own message or parse the same message more than once.