semvec/pypi-packages huggingface dataset:
keycloak-user-transfer 1.0.2
Yet another tool for transferring users from PostgreSQL to Keycloak using Keycloak REST API.
Requires Python: >3.8.*, <4

# keycloak-user-transfer

This is yet another tool for transferring huge amount of users from PostgreSQL to Keycloak using Keycloak REST API. 
It supports groups, custom user attributes, creation of disabled users and users with verified mail.

# Configuration

- db:
  - user_sql: Sql query for fetching users. (Remember: Cast all column types to varchar due bug in psycopg2) 
  - cursor_fetch_size: This script use PostgreSQL binary cursors to iterate large amount of user rows. You can set cursor fetch size with this value.
- keycloak:
  - base_url: Keycloak base url without trailling slash on end. Ex: https://sso.myhost.tld
  - realm: Which realm to insert users.
  - admin-cli-secret: Client secret of "Admin-cli" client. This script use service account on master realm to create users. You can learn more about service accounts in Keycloak [here](https://github.com/keycloak/keycloak-documentation/blob/main/server_admin/topics/clients/oidc/service-accounts.adoc). 
- mappings:
  - user_fields: Key-value mappings of user fields. Keys are Keycloak fields and values are the corresponding columns on the database.
  - user_attributes: Key-value mappings of user attributes. Keys are Keycloak fields and values are the corresponding columns on the database.
  - groups: Key-value mappings of group names and Keycloak IDs. (Groups must created before transfer.)
  - groups_field: Corresponding column that group names concatenate with delimiter.

This tool set random secure temporary password for user for additional security. You should send password reset mail to them. 

# Usage

After installing package from PyPI, define your config.yml path via KEYCLOAK_USER_TRANSFER_CONFIG environment variable then run `keycloak_user_transfer` command.
record-keeper 0.9.32
Record experiment data easily
Requires Python: >=3.0

# record-keeper

## Installation
```
pip install record-keeper
```

## The Problem:
When running machine-learning experiments, having more logged data is usually better than less. But adding new series of data to log can often require changes to your training code. When you want to log dozens of different series of data, your code starts to look awful.

## The Solution:

Use RecordKeeper, and easily add loggable information when you write a new class. The example below is modified from the [pytorch-metric-learning](https://github.com/KevinMusgrave/pytorch-metric-learning/blob/master/src/pytorch_metric_learning/miners/batch_hard_miner.py) library. 

First, create a list that contains the names of the attributes you want to record (```self._record_these``` in the example below).
```python
class BatchHardMiner(BaseTupleMiner):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self._record_these = ["hardest_triplet_dist", "hardest_pos_pair_dist", "hardest_neg_pair_dist"]
```

Then tell RecordKeeper the name of the list to read. RecordKeeper will log and save all the attributes described in the list. It'll search recursively too, if you have nested objects.
```python
from torch.utils.tensorboard import SummaryWriter
import record_keeper as record_keeper_package
from pytorch_metric_learning import miners

record_writer = record_keeper_package.RecordWriter(your_folder_for_logs)
tensorboard_writer = SummaryWriter(log_dir=your_tensorboard_folder)
record_keeper = record_keeper_package.RecordKeeper(tensorboard_writer, record_writer, ["_record_these"])

your_miner_dictionary = {"tuple_miner": miners.BatchHardMiner()}

# Then at each iteration of training:
record_keeper.update_records(your_miner_dictionary, current_iteration)
```

Now the attributes described in ```_record_these```, (specifically, ```hardest_triplet_dist```, ```hardest_pos_pair_dist```, and ```hardest_neg_pair_dist```) can be viewed on Tensorboard.

These data series are also saved in sqlite and CSV format. If you only want to use Tensorboard, then pass in only a SummaryWriter, and vice versa.

The dictionary that you pass into ```record_keeper.update_records``` can contain any number of objects, and for each one, RecordKeeper will check if the object has a "_record_these" attribute. As long as you're making your dictionaries programmatically, it's possible to add large amounts of loggable data without clogging up your training code. See [pytorch-metric-learning](https://github.com/KevinMusgrave/pytorch-metric-learning/) and [powerful-benchmarker](https://github.com/KevinMusgrave/powerful-benchmarker/) to see RecordKeeper in action.