<commit_before>==============
python-montage
==============

.. image:: https://circleci.com/gh/EditLLC/python-montage/tree/feature%2fv2.svg?style=shield
   :target: https://circleci.com/gh/EditLLC/python-montage/tree/feature%2fv2
   :alt: CircleCI

.. image:: https://codecov.io/github/EditLLC/python-montage/coverage.svg?branch=feature/v2
   :target: https://codecov.io/github/EditLLC/python-montage?branch=feature/v2
   :alt: Coverage

Python library for Montage

Usage
=====

::

    >>> import montage
    >>> client = montage.Client(subdomain[, token])
    >>> client.authenticate(email, password)  # sets client.token

    # Current user
    >>> client.user()

    # Querying and scripting
    >>> query = montage.Query('schema')
    >>> query = query.filter(**kwargs)
    >>> query = query.limit(10)
    >>> query = query.skip(10)
    >>> query = query.order_by(field[, ordering=asc|desc])

    >>> script = montage.Script('foobar.lua')

    >>> evaluated = montage.RunLua('''
    ...     function max(num1, num2)
    ...
    ...        if (num1 > num2) then
    ...           result = num1;
    ...        else
    ...           result = num2;
    ...        end
    ...
    ...        return result;
    ...     end
    ...
    ...     return max(10, 4)
    ... ''')

    >>> client.run(query=query, foobar=script, max=evaluated)
    {
        "data": {
            "query": [ ... ],
            "foobar": " ... ",
            "max": 10,
        }
    }

    # Schemas
    >>> client.schemas.list()
    >>> client.schemas.get('schema')

    # Data
    >>> client.documents.save(schema, *documents)
    >>> client.documents.get(schema, document_id)
    >>> client.documents.replace(schema, document)
    >>> client.documents.update(schema, document)
    >>> client.documents.remove(schema, document_id)

    # Files
    >>> client.files.list()
    >>> client.files.save(*files)
    >>> client.files.get(file_id)
    >>> client.files.remove(file_id)

    # Users
    >>> client.users.list()
    >>> client.users.list(email__endswith='gmail.com')
    >>> client.users.create(
    ...     full_name='<NAME>',
    ...     email='<EMAIL>',
    ...     password='<PASSWORD>'
    ... )
    >>> client.users.get(user_id)
    >>> client.users.update(user_id, password='<PASSWORD>')
    >>> client.users.remove(user_id)

    # Roles
    >>> client.roles.list()
    >>> client.roles.create(name='admins', add_users=['<user_id>'])
    >>> client.roles.get('admins')
    >>> client.roles.update('admins',
            add_users=['<user_id>'],
            remove_users=['<user_id>']
        )
    >>> client.roles.remove('admins')
<commit_msg>README example tweaks<commit_after>==============
python-montage
==============

.. image:: https://circleci.com/gh/EditLLC/python-montage/tree/feature%2fv2.svg?style=shield
   :target: https://circleci.com/gh/EditLLC/python-montage/tree/feature%2fv2
   :alt: CircleCI

.. image:: https://codecov.io/github/EditLLC/python-montage/coverage.svg?branch=feature/v2
   :target: https://codecov.io/github/EditLLC/python-montage?branch=feature/v2
   :alt: Coverage

Python library for Montage

Usage
=====

::

    >>> import montage
    >>> client = montage.Client(subdomain[, token])
    >>> client.authenticate(email, password)  # sets client.token

    # Current user
    >>> client.user()

    # Querying and scripting
    >>> query = (montage.Query('movies')
            .order_by(index='year')
            .filter(
                montage.Field('year') >= 1990
                montage.Field('year') < 2000
            )
        )
    >>> script = montage.Script('imdb/fetch-reviews.py', environ={
            'IMDB_MIN_SCORE': 8
        })
    >>> client.run(nineties_movies=query, reviews=script)
    {
        "data": {
            "nineties_movies": [ ... ],
            "reviews": " ... ",
        }
    }

    # Schemas
    >>> client.schemas.list()
    >>> client.schemas.get('schema')

    # Data
    >>> client.documents.save(schema, *documents)
    >>> client.documents.get(schema, document_id)
    >>> client.documents.replace(schema, document)
    >>> client.documents.update(schema, document)
    >>> client.documents.remove(schema, document_id)

    # Files
    >>> client.files.list()
    >>> client.files.save(*files)
    >>> client.files.get(file_id)
    >>> client.files.remove(file_id)

    # Users
    >>> client.users.list()
    >>> client.users.list(email__endswith='gmail.com')
    >>> client.users.create(
    ...     full_name='<NAME>',
    ...     email='<EMAIL>',
    ...     password='<PASSWORD>'
    ... )
    >>> client.users.get(user_id)
    >>> client.users.update(user_id, password='<PASSWORD>')
    >>> client.users.remove(user_id)

    # Roles
    >>> client.roles.list()
    >>> client.roles.create(name='admins', add_users=['<user_id>'])
    >>> client.roles.get('admins')
    >>> client.roles.update('admins',
            add_users=['<user_id>'],
            remove_users=['<user_id>']
        )
    >>> client.roles.remove('admins')

{'fraction_non_alphanumeric': 0.19848242811501599, 'fraction_numerical': 0.00718849840255591, 'mean_word_length': 2.4833101529902644, 'pattern_counts': {'":': 7, '<': 18, '<?xml version=': 0, '>': 208, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6379303', 'n_tokens_mistral': 1711, 'n_tokens_neox': 1632, 'n_words': 208}