semvec/pypi-packages huggingface dataset:
itranvias-api 0.1.1
Python API wrapper for the city of A Coruña public transport
Requires Python: >=3.9
Keywords: bus, buses, transport, public transport, galicia, api

# itranvias_api 🚍

[![GitHub license](https://img.shields.io/github/license/peprolinbot/itranvias_api)](https://github.com/peprolinbot/itranvias_api)
[![PyPI version](https://img.shields.io/pypi/v/itranvias_api?label=pypi%20package)](https://pypi.org/project/itranvias_api)

Python API wrapper for the city of A Coruña public transport ran by *Cia. Tranvías de La Coruña, S.A.*.

## 📜 Documentation

Documentation can be found [here](https://peprolinbot.github.io/itranvias_api). 

For the time being there is only one submodule: `itranvias_api.queryitr` which implements all (that I know of) functionality in the [official iTranvías client](https://itranvias.com/), using the "queryitr" API used by it, found at `https://itranvias.com/queryitr_v3.php`.

## 🔧 Installation

Just run:

``` bash
pip install itranvias_api
```

## 🖥️ CLI client

I have written a very simple, very basic POC, CLI client using this library, it is avaliable as `itranvias-cli` once the package is installed.

### Usage:
```
usage: itranvias-cli [-h] {stop,line} ...

Get real-time bus information for the city of A Coruña.

positional arguments:
  {stop,line}
    stop       Get next buses for a specific stop.
    line       Get buses and stops 'diagram' for a specific line and route.

options:
  -h, --help   show this help message and exit
```

## ⚠️ Disclaimer

This project is **not** endorsed by, directly affiliated with, maintained by, sponsored by or in any way officially related with la *Xunta de Galicia*, *Concello da Coruña*, *Cia. Tranvías de La Coruña, S.A.*, *SISTEMAS OLTON, S.L.* or any of the companies and entities involved in the [official iTranvías app](https://itranvias.com/).

This software is provided 'as is' without any warranty of any kind. The user of this software assumes all responsibility and risk for its use. I shall not be liable for any damages or misuse of this software. Please use the code and information in this repo responsibly.
gadfastemporal 0.0.1
Example repository demonstrating integration of Temporal workflows with FastAPI.
Requires Python: >=3.8

<p align="center">
  <a href="https://github.com/AlexDemure/gadfastemporal">
    <a href="https://ibb.co/8nnQPMQD"><img src="https://i.ibb.co/RGGJQ2Jp/logo.png" alt="logo" border="0"></a>
  </a>
</p>

<p align="center">
  Example repository demonstrating integration of Temporal workflows with FastAPI
</p>

---
### Temporal Python
- https://github.com/temporalio/samples-python
- https://github.com/temporalio/sdk-python

### Installation

```
pip install gadfastemporal
```

### Usage

```python
import contextlib
import contextvars
import typing
import uuid

from fastapi import FastAPI
from pydantic import BaseModel

from gadfastemporal import Temporal
from gadfastemporal import Workflow
from gadfastemporal import converters
from gadfastemporal import decorators
from gadfastemporal import interceptors

contextvar = contextvars.ContextVar("contextvar", default=None)

class Settings(BaseModel):
    TEMPORAL_HOST: str = "localhost:7233"
    TEMPORAL_NAMESPACE: str = "default"
    TEMPORAL_QUEUE: str = "my-queue"


settings = Settings()


@decorators.workflow
class SimpleWorkflow(Workflow):
    @staticmethod
    def id(_: dict) -> str:
        return str(uuid.uuid4())

    @staticmethod
    def activities() -> typing.List[typing.Callable]:
        return [SimpleWorkflow.process]

    @decorators.run
    async def run(self, command: dict) -> str:
        return await temporal.activity.sync(self.process, command)

    @staticmethod
    @decorators.activity
    async def process(data: dict) -> str:
        return f"Processed: {data}"


temporal = Temporal(
    host=settings.TEMPORAL_HOST,
    namespace=settings.TEMPORAL_NAMESPACE,
    task_queue=settings.TEMPORAL_QUEUE,
    workflows=[SimpleWorkflow],
    worker_interceptors=[interceptors.SentryInterceptor()],
    client_interceptors=[interceptors.ContextPropagationInterceptor(contexts=[contextvar])],
    data_converter=converters.pydantic,
    search_attributes=[contextvar],
)

@contextlib.asynccontextmanager
async def lifespan(_: FastAPI):
    await temporal.start()
    yield
    await temporal.shutdown()


app = FastAPI(lifespan=lifespan)

@app.post("/run")
async def run():
    data = dict(x=1)
    contextvar.set({"Traceparent": "12345"})
    return await temporal.workflow.sync(SimpleWorkflow, data)
```

Up containers
```
docker compose -f .compose/docker-compose.yml up -d --build
```

Create search-attribute
```
temporal operator search-attribute create --name Traceparent --type Keyword
```