semvec/pypi-packages huggingface dataset:
task-timer-birdhouses 1.0.1
You can use `TaskTimer` to automatically calculate and execute when a given function will be executed based on a specified duration in seconds.
Requires Python: >=3.7

# TaskTimer

`TaskTimer` is a Python class used to schedule and keep track of upcoming actions. You can use `TaskTimer` to automatically calculate and execute when a given function will be executed based on a specified duration in seconds.

# Usage
To use the TaskTimer class, you need to initialize an instance of the class with an action name, function and the amount of seconds until the function will be executed.

    from task_timer_birdhouses import TaskTimer

#### Initialize a new TaskTimer
    def greet(name):
        print(f"Hello, {name}!")

    task_timer = TaskTimer('greeting', 5, greet, args=["John"])

#### Print the next action time in a human-friendly format
    print(task_timer.human_friendly())

    # Output
    June 21, 2023, 02:11 AM

#### Print the next action time as a datetime object
    print(str(task_timer))

    # Output
    2023-06-21 02:11:05.046499

#### Print all upcoming actions
    print(TaskTimer.get_upcoming_actions())

    # Output
    {'send_email': 'June 21, 2023, 02:11 AM'}

In the example above, 'send_email' is the action we're scheduling, and 3600 is the number of seconds until the action will be executed.

### Other use cases
If you just want to add the sleep time in seconds to the current time you can do this:

        task_timer = TaskTimer('test', 5)

        print(task_timer)
        # Output
        2023-06-21 13:03:53.582599

        print(task_timer.human_friendly())
        # Output
        June 21, 2023, 02:11 AM

This might be useful if you use a different setup for executing your functions, and you only want to display the time a function will be executed.
## Installation

This package can be installed using pip:

```bash
pip install task-timer-birdhouses
pg-force-execute 0.0.dev0
Context manager to run PostgreSQL queries with SQLAlchemy, terminating any other clients that block them
Requires Python: >=3.7.1

# pg-force-execute

Context manager to run PostgreSQL queries with SQLAlchemy, terminating any other clients that continue to block it after a configurable delay.

Using this to wrap queries is somewhat of a last resort, but is useful in certain Extract Transform Load (ETL) pipeline contexts. For example, if it is more important to replace one table with another than to allow running queries on the table to complete, then this can be used to run the relevant `ALTER TABLE RENAME TO` query.


## Installation

`pg-force-execute` can be installed from PyPI using pip. `psycopg2` or `psycopg` (Psycopg 3) must also be explicitly installed.

```bash
pip install pg-force-execute psycopg
```


## Example usage

```python
import datetime
import sqlalchemy as sa
from pg_force_execute import pg_force_execute

# Run postgresql locally should allow the below to run
# docker run --rm -it -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 postgres

engine = sa.create_engine('postgresql+psycopg://postgres@127.0.0.1:5432/')
query = 'SELECT 1'  # A more realistic example would be something that needs an exclusive lock on a table

with \
        engine.begin() as conn, \
        pg_force_execute(
            conn,                                 # SQLAlchemy connection to run the query
            delay=datetime.timedelta(minutes=5),  # Amount of time to wait before cancelling queries
        ):

    results = conn.execute(sa.text(query))
    print(results.fetchall())
```


## API

The API a single context manager `pg_force_execute`.

`pg_force_execute`(conn, delay=datetime.timedelta(minutes=5), check_interval=datetime.timedelta(seconds=1), cleanup_timeout=datetime.timedelta(seconds=10), logger=logging.getLogger("pg_force_execute"))

- `conn` - A [SQLAlchemy connection](https://docs.sqlalchemy.org/en/20/core/connections.html#sqlalchemy.engine.Connection) that will be unblocked

- `delay` (optional) - How long to wait before attempting to terminate backends blocking `conn`

- `check_interval` (optional) - The interval between repeated attempts to terminate backends blocking `conn`

- `cleanup_timeout` (optional) - How long to wait for resources to be cleaned up before allowing exit of the context manager

    For usual operation this parameter shouldn't need to be changed.

- `logger` (optional) The Python logger instance through which to log


## Compatibility

- Python >= 3.7.1 (tested on 3.7.1, 3.8.0, 3.9.0, 3.10.0, and 3.11.0)
- psycopg2 >= 2.9.2 or Psycopg 3 >= 3.1.4
- SQLAlchemy >= 1.4.24 (tested on 1.4.24 and 2.0.0)
- PostgreSQL >= 9.6 (tested on 9.6, 10.0, 11.0, 12.0, 13.0, 14.0, and 15.0)

Note that SQLAlchemy < 2 does not support Psycopg 3.


## Running tests locally

```bash
python -m pip install -e ".[dev]"  # Only needed once
./start-services.sh                # Only needed once
pytest
```
gaohn-dsa 0.0.1
DSA package.
Requires Python: >=3.7

<div align="center">
<h1>Data Structures and Algorithm Documentation</a></h1>
by Hongnan Gao
Oct, 2022
<br>
</div>

This is the documentation for various data structures and algorithms concepts.

## Workflow

### Installation

```bash
~/gaohn                  $ git clone https://github.com/gao-hongnan/gaohn-dsa.git gaohn-dsa
~/gaohn                  $ cd gaohn-dsa
~/gaohn/gaohn-dsa        $ python -m venv <venv_name> && <venv_name>\Scripts\activate
~/gaohn/gaohn-dsa (venv) $ python -m pip install --upgrade pip setuptools wheel
~/gaohn/gaohn-dsa (venv) $ pip install -r requirements.txt
~/gaohn/gaohn-dsa (venv) $ pip install myst-nb==0.16.0
```

The reason for manual install of `myst-nb==0.16.0` is because it is not in sync
with the current jupyterbook version, I updated this feature to be able to show
line numbers in code cells.

### Setting up Continuous Integration

```bash
~/gaohn/gaohn-dsa (venv) $ mkdir -p .github/workflows .github/actions
```

```bash
~/gaohn/gaohn-dsa (venv) $ curl -o .github/actions/continuous-integration/action.yaml \
    https://raw.githubusercontent.com/gao-hongnan/common-utils/main/.github/actions/continuous-integration/template.yaml
```

```bash
~/gaohn/gaohn-dsa (venv) $ curl -o .github/workflows/continuous_integration.yaml \
    https://raw.githubusercontent.com/gao-hongnan/common-utils/main/.github/workflows/continuous_integration.yaml
```

Change the environment variable `PACKAGES_TO_CHECK` to `dsa` in
`.github/workflows/continuous_integration.yaml`.

### Building the book

After cloning, you can edit the books source files located in the `content/`
directory.

You run

```bash
~/gaohn (venv) $ jupyter-book build content/
```

to build the book, and

```bash
~/gaohn (venv) $ jupyter-book clean content/
```

to clean the build files.

A fully-rendered HTML version of the book will be built in
`content/_build/html/`.

## MyST NB

See
[config documentation](https://myst-nb.readthedocs.io/en/latest/configuration.html).