semvec/pypi-packages huggingface dataset:
syncopate 0.1.4
Pure asynchronous orchestrations
Requires Python: >=3.10

# Syncopate

> Tools for higher-order, pure orchestrations

## Usage

1. Define actions:

    ```python
    @dataclass
    class Greet:
        name: str
        
    @dataclass
    class Fetch:
        container: str
        num_items: int
        
    Action = Greet | Fetch
    ```

2. Define orchestration:

    ```python
    def orchestration() -> Generator[Action, Any, list[str]]:
        users = yield Fetch(container='users', num_items=3)
        for user in users:
            yield Greet(user)
        return users
    ```

3. Define executor:

   ```python
    def executor(action: Action):
        match action:
            case Greet():
                print(f"Hi, {action.name}!")
            case Fetch():
                print(f"Fetching {action.num_items} from '{action.container}'")
                return [f"User{i}" for i in range(action.num_items)]
   ```

4. Run!:

    ```python
    import syncopate

    await syncopate.run(orchestration, executor)
    # Fetching 3 from 'users'
    # Hi, User0!
    # Hi, User1!
    # Hi, User2!
    ```

## Installation

```bash
pip install syncopate
```

## Orchestrations and Executors

An executor is just a function of type

```python
Executor = Callable[[Action], Result | Awaitable[Result]]
```

`Action` and `Result` can be anything, as long as the orchestration you pair it with can handle them. An orchestration is just a generator function with type

```python
Orchestration = Generator[Action, Result, Return] # sends Action, receives Result, returns Return
```

## Combinators

Complexer behavior can be easily injected via `syncopate.combinators`. A combinator is just a higher-order function of type

```python
Combinator = Callable[Executor[Action, Result], Executor[Action2, Result2]]
```

### Example

For instance, parallel execution can be achieved using `combinators.parallelize`, roughly implemented as:

```python
def parallelize(executor: Executor[Action, Result]) -> Executor[Action | list[Action], Result | list[Result]]:
    async def _executor(actions):
        if isinstance(actions, list):
            return await asyncio.gather(*map(executor, actions))
        else:
            return await executor(action)
    
    return _executor
```

You can then use the same simple action executor but yield multiple actions to it for simultaneous execution:

```python
def parallel_orchestration() -> Generator[Action | list[Action], Any, list[str]]:
    users = yield Fetch(container='users', num_items=3)
    yield [Greet(user) for user in users]
    return users

syncopate.run(parallel_orchestration(), parallelize(executor))
```

### Composition

Multiple combinators (both in `syncopate.combinators` and custom) can be composed to create a new executor:

```python
from syncopate.combinators import parallel, logged

def custom_combinator(executor: Executor[...]) -> Executor[...]:
    ...

def executor(action: Action) -> Result:
    ...

custom_logged_parallel_executor = custom_combinator(logged(parallel(executor))) # please don't give variables such long names :)
```
metantic 0.2.0
Metaprogramming with pydantic Models (creating types from types)
Requires Python: >=3.10

# Metantic

> Metaprogramming with pydantic Models (creating types from types)

## Partial

> Create a partial model (all fields optional)

```python
from metantic import Partial

class User(BaseModel):
    id: str
    name: str
    age: int

Partial(User).model_validate(dict(id="id", name="name"))
# PartialUser(id='id', name='name', age=None)
```

## Fields

> Obtain a `Literal` type for the model's fields (which can be validated)

```python
from metantic import Fields

class User(BaseModel):
    id: str
    name: str
    age: int

Fields(User) # typing.Literal['id', 'name', 'age']

class Query(BaseModel):
    fields: Fields(User)

Query(fields=["id", "name"]) # OK
Query(fields=["email"]) # ValidationError: fields Input should be 'id', 'name' or 'age' [...]
```

## Omit

> Create a model with a subset of fields

```python
from metantic import Fields

class User(BaseModel):
    id: str
    name: str
    age: int

# the ID is unchangeable
def update(patch: Omit(User, ["id"])):
    ...
```

## Take

> Create a model with a subset of fields (recursively)

```python
class FullName(BaseModel):
    first: str; middle: str; family: str

class User(BaseModel):
    id: str
    full_name: FullName
    friends: list[str]
    
# field -> take the field
# (field, subfields) -> take field but with subfields only
UserInfo = Take(User, ['id', ('full_name': ['first', 'family'])])

# UserInfo is equivalent to
class UserInfo(BaseModel):
    id: str
    full_name: TakeFullName

class TakeFullName(BaseModel):
    first: str; family: str
```

## Paths

> Type-safe paths

### Validate

```python
from metantic import paths

class FullName(BaseModel):
    first: str; middle: str; family: str

class User(BaseModel):
    id: str
    full_name: FullName
    friends: list[str]
    
paths.validate(['full_name', 'first'], User.model_json_schema()) # None
paths.validate(['bad_name', 'first'], User.model_json_schema()) # ValueError("Key 'bad_name' doesn't exist in ['id', 'full_name', 'friends'])"
```

### Type

> Create a path `RootModel` with validation
>

```python
from metantic.paths import Path

UserPath = Path(User)

UserPath(root=['full_name', 'first']) # PathT(root=['full_name', 'first'])
UserPath(root=['bad_name', 'first']) # raises ValueError(...)

```

### Builder

> Currently under construction. May fail for some generic/union types

```python
from metantic import paths
    
ps = paths.builder(User) # PathBuilder object
ps['id'].path # ['id']
ps['full_name']['first'].path # ['full_name', 'first']
ps['friends'][69].path # ['friends', 69]

ps['full_name']['second'].path # ERROR



```

- Works with tuples, lists, dicts, classes and pydantic models
- Type unions stop path generation
bidirectional-text 0.1.0
A streamlit component that allows you to get input from a textbox after every key press
Requires Python: >=3.7

# bidirectional-text

A streamlit component that allows you to get input from a textbox after every key press

## Installation instructions 

```sh
pip install bidirectional-text
```

## Usage instructions

```python
import streamlit as st

from st_bidirectional_text import st_bidirectional_text

value = st_bidirectional_text()

st.write(value)
WordsPy 2.0.0
Get words for any langauge.
Keywords: python,words,extraction,word,lexicon


  

# WordsPy

  

  

A Python library allows developers to retrieve millions of words for the requested language with just one line of code.

  

  

![LexiExtract](https://raw.githubusercontent.com/eymenefealtun/WordsPy/master/RepoResources/WordsPyIcon.png)

  

  

[![PyPi](https://img.shields.io/pypi/v/wordspy)](https://pypi.org/project/wordspy/) [![Downloads](https://img.shields.io/pypi/dm/wordspy)](https://pypi.org/project/wordspy)

  
  
  

## Install

WordsPy can be installed using the pip command.

```

pip install WordsPy

```

  

## Example

```python

import WordsPy as Wp

english_language = Wp.English()

english_words = english_language.get_all_words() # return all the available words in language

random_english_words = Wp.get_random_words(turkish_words, 5) # retun 5 random words from the list

```

  

## Available languages

[All words in all languages](https://github.com/eymenefealtun/all-words-in-all-languages)

  
  

## How to contribute?

1. [Fork](https://github.com/eymenefealtun/WordsPy/fork) the repository.

2. Make changes.

3. Submit a pull request.

  

## How to support?

* [Buy me a coffee](https://www.buymeacoffee.com/altuneymenefe)

or

* Bitcoin: 19di2VDYV9cNrvrsqhZJeT8yXqwuRZ5PGx