Skip to content

Commit

Permalink
Merge branch 'master' of github.com:catalyst-team/alchemy
Browse files Browse the repository at this point in the history
  • Loading branch information
dkuryakin committed Jan 29, 2020
2 parents 4c50825 + c360054 commit b232cca
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 29 deletions.
141 changes: 139 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,139 @@
.idea/
venv/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
builds/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/



.DS_Store
.idea
.code

*.bak
*.csv
*.tsv
*.ipynb

tmp/
logs/
data/
!catalyst/data
examples/data/
# Examples - mock data
!examples/distilbert_text_classification/input/*.csv
!examples/_tests_distilbert_text_classification/input/*.csv
examples/logs/
notebooks/

_nogit*

### VisualStudioCode ###
.vscode/*
.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### VisualStudioCode Patch ###
# Ignore all local history of files
.history

# End of https://www.gitignore.io/api/visualstudiocode
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Copyright 2019 Sergey Kolesnikov. All rights reserved.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
replaced with your own identifying information. (Don"t include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
Expand Down
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,63 @@
# alchemy
<div align="center">

![Alchemy logo](https://raw.githubusercontent.com/catalyst-team/catalyst-pics/master/pics/alchemy_logo.png)

**Experiments logging & visualization**

[![Build Status](https://travis-ci.com/catalyst-team/alchemy.svg?branch=master)](https://travis-ci.com/catalyst-team/alchemy)
[![Pipi version](https://img.shields.io/pypi/v/alchemy-catalyst.svg)](https://pypi.org/project/alchemy-catalyst/)
[![Docs](https://img.shields.io/badge/dynamic/json.svg?label=docs&url=https%3A%2F%2Fpypi.org%2Fpypi%2Falchemy-catalyst%2Fjson&query=%24.info.version&colorB=brightgreen&prefix=v)](https://catalyst-team.github.io/alchemy-catalyst/index.html)
[![PyPI Status](https://pepy.tech/badge/alchemy-catalyst)](https://pepy.tech/project/alchemy-catalyst)
[![Github contributors](https://img.shields.io/github/contributors/catalyst-team/alchemy.svg?logo=github&logoColor=white)](https://github.com/catalyst-team/alchemy/graphs/contributors)

[![Twitter](https://img.shields.io/badge/news-on%20twitter-499feb)](https://t.me/catalyst_team)
[![Telegram](https://img.shields.io/badge/channel-on%20telegram-blue)](https://t.me/catalyst_team)
[![Spectrum](https://img.shields.io/badge/chat-on%20spectrum-blueviolet)](https://spectrum.chat/catalyst)
[![Slack](https://img.shields.io/badge/ODS-slack-red)](https://opendatascience.slack.com/messages/CGK4KQBHD)

</div>

Part of [Catalyst Ecosystem](https://docs.google.com/presentation/d/1D-yhVOg6OXzjo9K_-IS5vSHLPIUxp1PEkFGnpRcNCNU/edit?usp=sharing). Project [manifest](https://github.com/catalyst-team/catalyst/blob/master/MANIFEST.md).

---

## Installation

Common installation:
```bash
pip install -U alchemy-catalyst
```

## Getting started

1. Goto [Alchemy](https://alchemy.host/) and get your personal token.

2. Run following **example.py**:
```python
import random

from alchemy import Logger

token = "..." # insert your personal token here

for gid in range(1):
for eid in range(2):
for mid in range(3):
metric = f"metric_{mid}"
group = f"group_{gid}"
experiment = f"experiment_{eid}"

logger = Logger(token, experiment, group)

n = 300
x = random.randint(-10, 10)
for i in range(n):
logger.log_scalar(metric, x)
x += random.randint(-1, 1)
logger.close()
```
3. Now you should see your metrics on [Alchemy](https://alchemy.host/).

## Example

For mode detailed tutorials, please follow [Catalyst examples](https://github.com/catalyst-team/catalyst/tree/master/examples#tutorials).
Binary file added alchemy/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added alchemy/__pycache__/logger.cpython-37.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion alchemy/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.1"
__version__ = "0.0.2"
14 changes: 7 additions & 7 deletions alchemy/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from alchemy import Logger

token = '...'
token = "..."

for gid in range(3):
for eid in range(5):
for mid in range(10):
metric = f'metric_{mid}'
group = f'group_{gid}'
experiment = f'experiment_{eid}'
for gid in range(1):
for eid in range(2):
for mid in range(3):
metric = f"metric_{mid}"
group = f"group_{gid}"
experiment = f"experiment_{eid}"

logger = Logger(token, experiment, group)

Expand Down
30 changes: 15 additions & 15 deletions alchemy/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@


class Logger:
_url = 'https://alchemy.host/api/log'
_url = "https://alchemy.host/api/log"

def __init__(
self,
api_token: str,
experiment_name: str,
group_name: str = 'default',
project_name: str = 'default',
batch_size: int = 1000,
token: str,
experiment: str,
group: str = None,
project: str = None,
batch_size: int = None,
):
self._api_token = api_token
self._experiment_name = experiment_name
self._group_name = group_name
self._project_name = project_name
self._batch_size = batch_size
self._token = token
self._experiment = experiment
self._group = group or "default"
self._project = project or "default"
self._batch_size = batch_size or int(1e3)
self._counters = Counter()
self._queue = queue.Queue()
self._thread = threading.Thread(target=self._run_worker)
self._thread.start()

def _run_worker(self):
headers = {
'X-Token': self._api_token,
'X-Project': self._project_name,
'X-Group': self._group_name,
'X-Experiment': self._experiment_name,
'X-Token': self._token,
'X-Project': self._project,
'X-Group': self._group,
'X-Experiment': self._experiment,
}
running = True
while running:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from setuptools import find_packages, setup, Command

# Package meta-data.
NAME = "alchemy"
DESCRIPTION = "Alchemy. ML logging & visualization."
NAME = "alchemy-catalyst"
DESCRIPTION = "Alchemy. Experiments logging & visualization."
URL = "https://github.com/catalyst-team/alchemy"
EMAIL = "[email protected]"
AUTHOR = "David Kuryakin"
Expand Down

0 comments on commit b232cca

Please sign in to comment.