semvec/pypi-packages huggingface dataset:
metric-builder 2.1.4.4
Utility for building templated metric extraction queries that can be traversed through time.

# Metric Builder

Utility for building templated metric extraction queries that can be traversed through time.

## Prerequisites

You will need the following to run this code:
  * Python 3
  
## Installation

To be determined...

## Usage

In order to extract a given metric, a `Metric` object needs to be instantiated:

```python
metric = Metric(
    query="""
        SELECT count(*) AS total
        FROM `project.dataset.table`
        WHERE DATETIME_TRUNC(created_datetime, DAY) = '{{ reference_time | format_date('%Y-%m-%d') }}'
    """,
    reader = BigQueryReader(json_credentials_path='/path/to/creds.json')
)
```

The `query` parameter is a templated query where you can format the `reference_time` `datetime` object to the required format using template filters.

The `reader` parameter is the object that is actually going to connect to the desired database and perform the queries.

The `metric` object can now be used to fetch metrics for a given point in time as follows:

```python
result = metric.fetch(reference_time=datetime.date(2019, 10, 21))
```

The result is returned as a list of dictionaries.

### Template filters

[Jinja2](https://jinja.palletsprojects.com/en/2.10.x/) is used as the templating engine. All built in Jinja filters are thus available. Relevant custom template filters have been added though for convenience:

#### format_date

Specify format of datetime:

```
'{{ reference_time | format_date('%Y-%m-%d') }}'
```

#### day_delta

Change a given datetime object by a specified number of days:

```
'{{ reference_time | day_delta(-7) | format_date('%Y-%m-%d') }}'
```

### Readers

Any reader will implement the following method that is used to execute queries:

```python
def execute(self, query) -> List[Dict[str, Any]]:
    ...
```

#### BigQueryReader

The underlying client is required to be authenticated with the necessary priviledges to read from the requested BigQuery tables.

If you authenticate with:

```bash
gcloud auth login
```

or

```bash
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/keyfile.json"
```

then you can just instantiate your `Reader` like this:

```python
reader = BigQueryReader()
```

The other option is to explicitly authenticate with a service account key file:

```python
reader = BigQueryReader(json_credentials_path='/path/to/creds.json')
```

#### HiveReader

Coming soon...
imc2zarr 0.2.0
IMC scan to Zarr conversion
Requires Python: >=3.7

# IMC to Zarr converter

Convert IMC scan dataset to Zarr.

## Install

```
pip install imc2zarr
```

### Requirements

* click
* numpy
* pandas
* python_dateutil
* xarray

## Usage

### Arguments
* input_path:
  * the root folder of the IMC scan containing a single mcd file and/or other related files: XML meta & scan data in text format
  * or, the path of an mcd file
* output_path: the location where to store the converted output in Zarr format 

### From Python script

```
from imc2zarr import imc2zarr

imc2zarr(input_path, output_path)
```

### From the command line

```
imc2zarr input_path output_path
```
git-ignores 0.1.1
.gitignore generator built as a git plugin
Requires Python: >=3.11,<4.0

# git-ignores

Git plugin that generates a .gitignore for your project based on Githubs gitignore templates.

## Usage

The plugin provides a new git subcommand `ignores`. which takes the following options.

- `--template` - The name of the gitignore template from 
  [this repo](https://github.com/github/gitignore) (_i.e_ `Python` or `Javascript`)

- `--append` - Instead of failing or replacing content, `--append` will tell the 
script to simply append the gitignore entries instead of replacing the file wholesale.

- `--force` - Replace the .gitignore file by force with the new template.

> You can also run `git-ignores --help` to view the help message. Note that `git ignores --help` returns an error as git tries to load a man page when --help is called. A man-page will be shipped in a future update.

### Example

```
$ git ignores -t Python --force
```

## Installation

__FIXME__

## Contributing

If you wish to contribute to the project. Here a few things to note.

- Python version used in development: 3.11
- This project uses the [Poetry](https://python-poetry.org/) build tool.

## Todo
- [ ] Tests
- [ ] Cleanup and validate package metadata
- [ ] Publish on PyPi
coloriv 3.2
basic utils for python3

# coloriv
Utilities from python3 including coloful logs, procedure logs timer, basic 
image operation and so on.

## Install
```bash
$ pip install coloriv
```

## Components

### Cache
An quick data storage support [pickle, str, bin, json].

#### Functions
|Function|Instruction|
|:--|:--|
|items|Lists items of caches.|
|remove|Deletes a cache file.|
|dump|Saves or rewrites a cache file.|
|load|Loads from a cache file.|

#### Examples
```python
from coloriv.cache import Cache
cache = Cache('/tmp/data')
cache.dump(data={'hi', 'hello'}, name='greeting.pkl')
print(cache.load(name='greeting.pkl'))
cache.dump(data='hi'.encode('utf-8'), name='greeting.bin', file_type='bin')
print(cache.load(name='greeting.bin', file_type='bin'))
cache.dump(data={'hi': 'hello'}, name='greeting.json', file_type='json')
print(cache.load(name='greeting.json', file_type='json'))
cache.dump(data={'hi', 'hello'}, name='greeting.txt', file_type='str')
print(cache.load(name='greeting.txt', file_type='str'))

print(cache.items())
cache.remove('greeting.txt')
print(cache.items())
```
![image](https://github.com/indestinee/utils/raw/master/images/cache.jpg)

### colorful_str
#### Color List
|Code|Code1|Color|
|:--|:--|:--|
|(#r)|(#red)|red|
|(#g)|(#green)|green|
|(#y)|(#yellow)|yellow|
|(#b)|(#blue)|blue|
|(#w)|(#white)|white|
|(#magenta)||magenta|
|(#black)||black|
|(#cyan)||cyan|
|(#)||default|

#### Examples
```python
from coloriv.base import colorful_str
print(colorful_str('(#r)this is a red message.(#)',
				   'this is a normal message.',
				   '(#b)this is a blue value {}(#).'.format(2),
				   '(#g)this is a green dict {}.'.format({1:2})))
print(colorful_str.log('(#r)this is a red message.(#)',
					   'this is a normal message.',
					   '(#b)this is a blue value {}(#).'.format(2),
					   '(#g)this is a green dict {}.'.format({1:2})))
print(colorful_str.suc('(#r)this is a red message.(#)',
					   'this is a normal message.',
					   '(#b)this is a blue value {}(#).'.format(2),
					   '(#g)this is a green dict {}.'.format({1:2})))
print(colorful_str.err('(#r)this is a red message.(#)',
					   'this is a normal message.',
					   '(#b)this is a blue value {}(#).'.format(2),
					   '(#g)this is a green dict {}.'.format({1:2})))
print(colorful_str.wrn('(#r)this is a red message.(#)',
					   'this is a normal message.',
					   '(#b)this is a blue value {}(#).'.format(2),
					   '(#g)this is a green dict {}.'.format({1:2})))
print(colorful_str.dict({'a': 's', 'b': 's'}))
```

![image](https://github.com/indestinee/utils/raw/master/images/colorful_str.jpg)

### procedure
Log and Timer for a block of codes.

#### Examples
```python
from coloriv.base import procedure
with procedure('hi') as p:
    x = 123 + 123
    p.show_time('x has be calculated.', x)
    p.add_log('x =', x)
    y = x + 34
    p.add_log('y =', y)

with procedure('hi', new_line=True):
    pass
```

![image](https://github.com/indestinee/utils/raw/master/images/procedure.jpg)