Skip to content

Commit

Permalink
add projects & workspaces support
Browse files Browse the repository at this point in the history
  • Loading branch information
dkuryakin committed Jan 29, 2020
1 parent 69411aa commit 4c50825
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion alchemy/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

for gid in range(3):
for eid in range(5):
for mid in range(100):
for mid in range(10):
metric = f'metric_{mid}'
group = f'group_{gid}'
experiment = f'experiment_{eid}'
Expand Down
26 changes: 15 additions & 11 deletions alchemy/logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import queue
import threading
from collections import Counter
from typing import Union

import requests
Expand All @@ -10,22 +11,29 @@ class Logger:

def __init__(
self,
token: str,
api_token: str,
experiment_name: str,
group_name: str = 'defult',
group_name: str = 'default',
project_name: str = 'default',
batch_size: int = 1000,
):
self._token = token
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._counters = dict()
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._token}
headers = {
'X-Token': self._api_token,
'X-Project': self._project_name,
'X-Group': self._group_name,
'X-Experiment': self._experiment_name,
}
running = True
while running:
batch = []
Expand Down Expand Up @@ -55,13 +63,9 @@ def log_scalar(
name: str,
value: Union[int, float],
):
step = self._counters.get('log_scalar', 0)
self._queue.put(dict(
group=self._group_name,
experiment=self._experiment_name,
type='log_scalar',
name=name,
value=value,
step=step,
step=self._counters[name],
))
self._counters['log_scalar'] = step + 1
self._counters[name] += 1

0 comments on commit 4c50825

Please sign in to comment.