semvec/pypi-packages huggingface dataset:
keras-flops 0.1.2
FLOPs calculator with tf.profiler for neural network architecture written in tensorflow 2.2+ (tf.keras)
License: MIT
Requires Python: >=3.6,<4.0
Keywords: tensorflow2,flops,profiler

# keras-flops

![](https://github.com/tokusumi/keras-flops/workflows/Tests/badge.svg)
[![PyPI version](https://badge.fury.io/py/keras-flops.svg)](https://badge.fury.io/py/keras-flops)

FLOPs calculator for neural network architecture written in tensorflow (tf.keras) v2.2+

This stands on the shoulders of giants, [tf.profiler](https://www.tensorflow.org/api_docs/python/tf/compat/v1/profiler/Profiler). 

## Requirements

* Python 3.6+
* Tensorflow 2.2+

## Installation

Using pip:

```
pip install keras-flops
```

## Example

See colab examples [here](https://github.com/tokusumi/keras-flops/tree/master/notebooks) in details.

```python
from tensorflow.keras import Model, Input
from tensorflow.keras.layers import Dense, Flatten, Conv2D, MaxPooling2D, Dropout

from keras_flops import get_flops

# build model
inp = Input((32, 32, 3))
x = Conv2D(32, kernel_size=(3, 3), activation="relu")(inp)
x = Conv2D(64, (3, 3), activation="relu")(x)
x = MaxPooling2D(pool_size=(2, 2))(x)
x = Dropout(0.25)(x)
x = Flatten()(x)
x = Dense(128, activation="relu")(x)
x = Dropout(0.5)(x)
out = Dense(10, activation="softmax")(x)
model = Model(inp, out)

# Calculae FLOPS
flops = get_flops(model, batch_size=1)
print(f"FLOPS: {flops / 10 ** 9:.03} G")
# >>> FLOPS: 0.0338 G
```

## Support

Support `tf.keras.layers` as follows,

| name | layer | 
| -- | -- |
| Conv | Conv[1D/2D/3D]|
| | Conv[1D/2D]Transpose |
| | DepthwiseConv2D |
| | SeparableConv[1D/2D] |
| Pooling | AveragePooling[1D/2D] |
| | GlobalAveragePooling[1D/2D/3D]|
| | MaxPooling[1D/2D] |
| | GlobalMaxPool[1D/2D/3D] |
| Normalization | BatchNormalization |
| Activation | Softmax |
| Attention | Attention |
| | AdditiveAttention |
| others | Dense |

## Not supported

Not support `tf.keras.layers` as follows. They are calculated as zero or smaller value than correct value.

| name | layer | 
| -- | -- |
| Conv | Conv3DTranspose |
| Pooling | AveragePooling3D |
| | MaxPooling3D |
| | UpSampling[1D/2D/3D] |
| Normalization | LayerNormalization |
| RNN | SimpleRNN |
| | LSTM |
| | GRU |
| others | Embedding |
maillogger 0.2.0
Analysis tool for Postfix log in /var/log/maillog
License: MIT
Requires Python: >=3.7,<4.0
Keywords: postfix,maillog

# maillogger

![PyPI](https://img.shields.io/pypi/v/maillogger)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/maillogger)
![PyPI - License](https://img.shields.io/pypi/l/maillogger)

Analysis tool for Postfix log in /var/log/maillog

<!-- TOC depthFrom:2 -->

- [Feature](#feature)
- [Installation](#installation)
- [Usage](#usage)
- [Examples](#examples)
  - [Output a CSV file](#output-a-csv-file)
  - [Output a JSON file](#output-a-json-file)
  - [Output a TSV file](#output-a-tsv-file)
  - [Output a compressed CSV file](#output-a-compressed-csv-file)
- [Use Case](#use-case)
  - [Analysis using MySQL](#analysis-using-mysql)

<!-- /TOC -->

## Feature

- Load maillog file
  - Identify text or gzip automatically
- Parse maillog
  - Use regex
  - Convert to Python dictionary
- Output the parsed maillog to files
  - Supported data format is CSV, TSV and JSON
  - Compression (gzip) is possible

## Installation

```bash
pip install maillogger
```

## Usage

```
usage: maillogger [-h] [-f {csv,tsv,json}] [-c] [-V] source_file target_file

Analysis tool for Postfix log in /var/log/maillog

positional arguments:
  source_file           Specify Postfix maillog file
  target_file           Specify the filename to write parsed maillog. The file
                        extension is automatically added to the end of
                        filename.

optional arguments:
  -h, --help            show this help message and exit
  -f {csv,tsv,json}, --format {csv,tsv,json}
                        File data format to write the parsed maillog (Default:
                        csv)
  -c, --compress        Compress the output file with gzip
  -V, --version         Show maillogger command version
```

## Examples

### Output a CSV file

```bash
maillogger /var/log/maillog result
```

or

```bash
maillogger /var/log/maillog result -f csv
```

Then, `result.csv` is generated in current working directory.

### Output a JSON file

```bash
maillogger /var/log/maillog result -f json
```

### Output a TSV file

```bash
maillogger /var/log/maillog result -f tsv
```

### Output a compressed CSV file

```bash
maillogger /var/log/maillog result -f csv -c
```

Then, `result.csv.gz` is generated in current working directory.

## Use Case

### Analysis using MySQL

1. Convert maillog text to CSV file

```bash
maillogger /var/log/maillog /path/to/any -f csv
```

2. Create Table

```sql
CREATE TABLE maillog
(
    mail_id VARCHAR(15) NOT NULL,
    to_address VARCHAR(50) NOT NULL,
    relay text,
    delay VARCHAR(10),
    delays VARCHAR(20),
    dsn VARCHAR(10),
    status VARCHAR(10),
    description text,
    datetime DATETIME NOT NULL,
    PRIMARY KEY (mail_id, datetime),
    INDEX i_status(status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
```

3. Load CSV file

```sql
LOAD DATA INFILE '/path/to/any.csv'
IGNORE INTO TABLE maillog
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
```
django-loggable-util 0.0.4
Separate logging from class based view business code
License: MIT
Keywords: Django,Loggable,Wrapper,Generic view,Class based view

# Django loggable util

An utility to create logs for request and response while keeping business code clean for class based views. 

### Motivation
By using generic view, we can write a view as concise as this:

```python
class SomeModelCreateView(LoginRequiredMixin, CreateView):
    model = SomeModel
```
As we can see there is no place where we can write `logger.info(...)`. It won't be pretty to override some methods in the view just for printing logs.
It would make sense if there is already some overridden method in the view, then we could've put the logger 
method there. That's why this package is created to quickly enable request and response logs for class based views.



### Installation

```shell script
pip install djang-loggable-util
```

### Example usage

Import the `Loggable` class in your urls.py
```python
from django_loggable_util import Loggable
```

Now write url configuration as this:

```python
urlpatterns=[
...
path('someurl', Loggable(SomeCBView).as_view(),name='some-url-name'),
...
]
```

You can pass usual parameters like `template_name` etc, in `as_view()` function.

This will result in logs like this for every request response cycle:

```text
INFO | 2020-08-17 09:10:12.764 | {'request': {'method': 'GET', 'path': '/someurl', 'username': 'someuser', 'params': <QueryDict: {'somekey':'someval'}>}}
INFO | 2020-08-17 09:10:12.777 | {'response': {'username': 'someuser', 'status_code': 200, 'template': ['sometemplate.html']}}
```

A default configuration is embedded with this package:
```python
default_log_config = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'request_response_formatter': {
            'format': '%(levelname)s | %(asctime)s.%(msecs)03d | %(message)s',
            'datefmt': "%Y-%m-%d %H:%M:%S",
        }
    },
    'handlers': {
        'request_response_console': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'formatter': 'request_response_formatter'
        }

    },
    'loggers': {
        'request_response': {
            'handlers': ['request_response_console'],
            'level': 'INFO',
            'propagate': False
        }
    }
}
```
This configuration streams logs to console. When it is needed to stream logs to files or any other service, 
you can add that logging configuration in `settings.py` and provide logger name to use for this library like this:

```python
LOGGABLE_LOGGER='your_logger_name'
```

### Todos
 - Write Tests
 - Support DRF
 - Support FBV

License
----

MIT

**Free Software, Hell Yeah!**