semvec/pypi-packages huggingface dataset:
nerdpool-client 1.1.0
A client for Nerdpool-Api
License: MIT

[![Run Tests](https://github.com/acdh-oeaw/nerdpool-client/actions/workflows/test.yml/badge.svg)](https://github.com/acdh-oeaw/nerdpool-client/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/acdh-oeaw/nerdpool-client/branch/master/graph/badge.svg?token=LXKIMGDXXF)](https://codecov.io/gh/acdh-oeaw/nerdpool-client) [![PyPI version](https://badge.fury.io/py/nerdpool-client.svg)](https://badge.fury.io/py/nerdpool-client)

# nerdpool-client

A Python client for downloading data from https://nerdpool-api.acdh-dev.oeaw.ac.at

## install

`pip install nerdpool_client`

## usage

### list data set titles


```python

from nerdpool_client import NerdPoolClient

client = NerdPoolClient()
print(client.data_sets)
# ['RTA', 'RITA', 'MRP', 'Chronik Aldersbach', 'DIPKO']
```

### download samples as .jsonl file

* go to [nerdpool-api](https://nerdpool-api.acdh-dev.oeaw.ac.at/) and create/filter you'r prefered data sample; e.g. all samples from MRP: 

```python

from nerdpool_client import NerdPoolClient

url = "https://nerdpool-api.acdh-dev.oeaw.ac.at/api/ner-sample/?format=json&ner_ent_type__contains=&ner_source__title=MRP"
client = NerdPoolClient()
client.dump_to_jsonl(url)
# 'out.jsonl'
```

### download samples as test.jsonl and eval.jsonl files

* With `file_name_prefix` you can add a custom prefix to the default file names `train.jsonl` and `eval.jsonl`
* The param `split` defines that each `split` sample should be saved into `eval.jsonl` and not into `train.jsonl`

```python
from nerdpool_client import NerdPoolClient

url = "https://nerdpool-api.acdh-dev.oeaw.ac.at/api/ner-sample/?format=json&ner_ent_type__contains=&ner_source__title=MRP"
client = NerdPoolClient()
client.dump_to_train_eval(url, file_name_prefix="mrp__", split=10)
# ['mrp__train.jsonl', 'mrp__eval.jsonl]
```
django-model-snapshot-diff 1.0.1
Django model snapshot difference
License: MIT
Keywords: make django model snapshot with relations get difference

# Django model snapshot difference
Make snapshot from Django model with all deep relations and get difference

Example models with other relations like OneToOne, ManyToMany etc.:

```python
from django.db import models
from django_model_snapshot_diff.mixins import SnapshotMixin
from django_model_snapshot_diff.models import SnapshotModel


class ManyToMany(SnapshotMixin, models.Model):
    description = models.CharField(max_length=255)

    snapshot_fields = [
        ('description', 'ManyToMany DESCRIPTION field'),
    ]


class ForeignKeyDeeper(SnapshotMixin, models.Model):
    name = models.CharField(max_length=255)
    many_to_many = models.ManyToManyField('example.ManyToMany')

    snapshot_fields = [
        ('name', 'ForeignKeyDeeper NAME field'),
        ('many_to_many', 'ForeignKeyDeeper MANYTOMANY field'),
    ]


class ForeignKey(SnapshotMixin, models.Model):
    title = models.CharField(max_length=255)
    foreign_key_deeper = models.ForeignKey('example.ForeignKeyDeeper',
                                           on_delete=models.CASCADE)

    snapshot_fields = [
        ('title', 'ForeignKey TITLE field'),
        ('foreign_key_deeper', 'ForeignKey DEEPER field'),
    ]


class Relation(SnapshotMixin, models.Model):
    choice = models.CharField(choices=((1, 'A'), (2, 'B')), default=1,
                              max_length=2)
    rel_to_example = models.ForeignKey('example.Example',
                                       on_delete=models.CASCADE,
                                       related_name='relation_to_example')

    snapshot_fields = [
        ('choice', 'Relation CHOICE field'),
    ]


class Example(SnapshotModel):
    text = models.CharField(max_length=255)
    boolean = models.BooleanField(default=False)
    datetime = models.DateTimeField(auto_now=True)
    foreign_key = models.ForeignKey('example.ForeignKey',
                                    on_delete=models.CASCADE)

    snapshot_fields = [
        ('text', 'Example TEXT field'),
        ('boolean', 'Example BOOL field'),
        ('datetime', 'Example DATETIME field'),
        ('foreign_key', 'Example ForeignKey field'),
        ('relation_to_example', 'Example Relation field'),
    ]
```
snapshot_fields should be a list of tuples with fields to track, for example:
```python
snapshot_fields = [
    ('model_field_name', 'Verbose name, any text')
]
```
How to use?
```python
example = Example.objects.first()
example.save_snapshot()

example.text = 'new text'
example.save()

diff = example.diff(verbose=True)
assert diff == {'Example TEXT field': {'New Value:': 'new text',
                                        'Old Value': 'text'}}
```
Diff will contain all difference with relations, for full example look for a tests.
# Testing

Tests are found in a simplified Django project in the ```/testapp``` folder. Install the project requirements and do ```./manage.py test``` to run them.

# License

See [License](LICENSE.md).