semvec/pypi-packages huggingface dataset:
performance-logger 1.0.3
check performance of the func using decorator
Requires Python: >=3
Keywords: performance_logger

# performance_logger

## Table of Contents
  * [Installation](#installation)
  * [Quick start](#quick-start)
  * [Features](#features)
  
## Installation

Download using pip via pypi.

```bash
$ pip install performance-logger --upgrade
```
(Mac/homebrew users may need to use ``pip3``)


## Quick start
```python
from performance_logger.main import perf_logger

@perf_logger('datetime')
def test_fun():
    return "it will log the time performance of test_fun using datetime format"

@perf_logger('ns')
def test_fun2():
    return "it will log the time performance of test_fun2 using nano seconds"
```

## Features
  * Simple decorator functions for performance checking of functions
  * You can use parameter to choose logged performace format
edgefarm-application-sdk.py 0.1.2
A python library for EdgeFarm applications

# edgefarm-application-sdk.py
A python library for EdgeFarm applications.

Supported features
* Communicate with Service Modules
    * [alm-mqtt-module](./edgefarm_application_sdk/alm_mqtt_module)
    * [ads-node-module](./edgefarm_application_sdk/ads_node_module)

This library is using [asyncio](https://docs.python.org/3/library/asyncio.html) and therefore the application must use the design patters required for asyncio.

## Installation via pip
```
pip3 install edgefarm-application-sdk.py
```

## Example usage:
```python
import edgefarm_application_sdk as ef

async def subject_handler(msg):
    payload = json.loads(msg["payload"])
    print(f"{msg}: payload={payload}")


async def main():
    # Initialize Edgefarm Application SDK
    await ef.application_module_init_from_environment(asyncio.get_event_loop())

    # Publish a message to Application Data Service (ADS)
    ads = ef.AdsProducer()

    # Create an encoder for an application specific payload
    payload_schema = { .... }  # replace with your avro schema

    encoder = ef.AdsEncoder(
        payload_schema,
        schema_name="temperature_data",
        schema_version=(1, 0, 0),
        tags={"monitor": "channel1"},
    )

    ads_payload = { 'mydata': 1234 }

    await ads.encode_and_send(encoder, ads_payload)


    # Connect to ALM MQTT module and register the MQTT subjects we want to receive
    mqtt_client = AlmMqttModuleClient()
    await mqtt_client.subscribe("simulation/temperature", subject_handler)

    #
    # The following shuts down gracefully when SIGINT or SIGTERM is received
    #
    stop = {"stop": False}

    def signal_handler():
        stop["stop"] = True

    for sig in ("SIGINT", "SIGTERM"):
        loop.add_signal_handler(getattr(signal, sig), signal_handler)

    while not stop["stop"]:
        await asyncio.sleep(1)

    print("Unsubscribing and shutting down...")
    await mqtt_client.close()
    await ef.application_module_term()


if __name__ == "__main__":
    asyncio.run(main())
```

## Compatibility

Compatible with Python >= 3.8

## Running examples

(You can ignore these instructions if you installed this SDK via pip)

When you have cloned this repo and want to run the code in `examples`, ensure that you have the `edgefarm_application_sdk` in your `PYTHONPATH`, e.g.
```bash
export PYTHONPATH=<this-repo-checkout-path>:${PYTHONPATH}
```

Furthermore, load required schemas from [ads_schema repo](https://github.com/edgefarm/ads-schemas.git):
```bash
make
```
ordered-argparse 1.0.10
Modified version of argparse which remembers the order of CLI arguments
Requires Python: >=3.9
Keywords: cli argument parsing

# ordered_argparse

Version of Python's standard library's `argparse` which also remembers the order of command line arguments.

## Installation

Install with `pip install ordered_argparse`.

## Usage

Create an instance of `ArgumentParser` as usual. Use `namespace=ordered_argparse.OrderedNamespace()`. Access arguments in declaration order by calling parser's `.ordered()` method.

```python
import ordered_argparse

parser = ordered_argparse.ArgumentParser()
parser.add_argument("--foo", action="store_true", help="foo")
parser.add_argument("--bar", action="store_true", help="bar")

# Use OrderedNamespace when parsing CLI arguments
args = parser.parse_args(["--foo", "--bar"], namespace=ordered_argparse.OrderedNamespace())

# Access ordered arguments by calling .ordered()
for arg in args.ordered():
    print(f"{arg}")
```

## Compatibility with argcomplete

ordered_argparse only works with `argcomplete` as long as you don't use subparsers. If you use subparsers, you need `ordered_argcomplete`.
drf_pyjwt 0.0.8
A JSON Web Token authentication extension for the Django REST Framework.
Requires Python: >=3.8

# drf_pyjwt
A JSON Web Token authentication extension for the Django REST Framework

[![PyPI Version][pypi-image]][pypi-url]
[![Maintainability](https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/maintainability)](https://codeclimate.com/github/vskrachkov/drf_pyjwt/maintainability)

[pypi-image]: https://img.shields.io/pypi/v/drf_pyjwt
[pypi-url]: https://pypi.org/project/drf_pyjwt/

# Installation

Using pip

`pip install drf_pyjwt`

Using pipenv

`pipenv install drf_pyjwt`

# Quick start
In your project’s `settings.py` add these settings.

```
DRF_PYJWT_JWKS_URI = "https://api.sample/jwks.json"
DRF_PYJWT_ALGORITHMS = ["RS256"]
DRF_PYJWT_KWARGS = {"audience": "https://api.sample"}
```

In `views.py` add `PyJWTAuthentication` class to authentication classes.

``` 
@api_view(["get"])
@authentication_classes([PyJWTAuthentication])
def example(request: Request) -> Response:
    token: dict = request.auth
    print("Access token: {token}")
    return Response({"some": "response"})
```

By default `PyJWTAuthentication` cannot lookup user by token, that's why you will get `None` in `request.user`. 
You can provide lookup user function using `DRF_PYJWT_LOOKUP_USER` setting. 
After this `PyJWTAuthentication` will populate `request.user` using provided function.

# Settings Reference
### DRF_PYJWT_JWKS_URI
Required: `True`

Type: `str`

Value which will be passed as `uri` argument to [jwt.jwks_client.PyJWKClient]() function 

### DRF_PYJWT_ALGORITHMS
Required: `False`

Type: `List[str]`

Default: `["RS256"]`

Example: `DRF_PYJWT_ALGORITHMS = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json"`

Value which will be passed as `algorithms` argument to [jwt.decode](https://pyjwt.readthedocs.io/en/stable/api.html?highlight=decode#jwt.decode) function.

### DRF_PYJWT_OPTIONS
Required: `False`

Type: `dict`

Example: `DRF_PYJWT_OPTIONS = {"verify_exp": False}`

Value which will be passed as `options` argument to [jwt.decode](https://pyjwt.readthedocs.io/en/stable/api.html?highlight=decode#jwt.decode) function.

### DRF_PYJWT_KWARGS
Required: `False`

Type: `dict`

Example: `DRF_PYJWT_KWARGS = {"audience": "https://app.domain"}`

Value which will be passed as `**kwargs` argument to [jwt.decode](https://pyjwt.readthedocs.io/en/stable/api.html?highlight=decode#jwt.decode) function.

### DRF_PYJWT_LOOKUP_USER
Required: `False`

Type: `str` (Import path to the `Callable[[dict], Optional[AbstractBaseUser]]`)

Example:
```
def lookup_user(token: dict) -> Optional[AbstractBaseUser]:
    user_id = token["custom_claim_user_id"]
    user = User.objects.filter(pk=user_id).first()
    return user
```