Metadata-Version: 2.1
Name: couchbed
Version: 0.1.7
Summary: Logging into CouchDB.
Author: chocolate-icecream
Keywords: CouchDB
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: License :: OSI Approved :: MIT License
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE.txt

# CouchBed

CouchBed is a Python library that allows you to log your code execution into CouchDB. It provides a simple and convenient way to record settings, messages, and logs into a CouchDB database.

## Installation

You can install CouchBed using pip:

```shell
pip install couchbed
```

## Usage

First, import the `CouchBed` class from the `couchbed` module:

```python
from couchbed import CouchBed
```

Create an instance of the `CouchBed` class, specifying the name of the CouchDB database as a parameter. By default, CouchBed uses the CouchDB URI provided by the `PYTHON_COUCHBED` environment variable. Alternatively, you can pass the URI as a parameter when creating the `CouchBed` instance. For each trial, you prepare a new book (CBBook).

```python
couch = CouchBed("__DATABASE_NAME__")
book = couch.new_book()
```

### Recording Settings

You can record settings by using the `set` method or by directly assigning values to keys in the `CBBook` instance.

```python
book.set({"a": 1, "b": 2})
# or
book["key"] = "value"
```

### Accessing Settings

You can access the recorded settings by using the `CBBook` instance as a dictionary.

```python
print(book["a"])
```

### Recording Messages

You can record messages by calling the `CBBook` instance as a function and passing the desired message as arguments.

```python
book("Hello", 1, 2, 3)
```

### Recording Logs

You can record logs by using the `log` method and passing a dictionary containing the log information.

```python
book.log({"epoch": 1, "train_loss": 0.1, "val_loss": 0.15})
```

### Saving Data

CouchBed automatically saves the data every 5 seconds if there are any changes. However, it's recommended to explicitly call the `save` method at the end of your program to ensure all the data is saved. Otherwise, the last 5-second data may be lost.

```python
book.save()
# or
couch.save()
```

## License

CouchBed is licensed under the MIT License.
