Skip to content

Commit c882235

Browse files
committed
Update usage notes in README
1 parent ffebe2e commit c882235

File tree

5 files changed

+43
-17
lines changed

5 files changed

+43
-17
lines changed

README.md

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,58 @@ It is easy to send messages after token is issued. Just install `telepyth`
3232
package by `pip install telepyth`, import it and notify
3333

3434
```python
35-
import telepyth
35+
import telepyth
3636

37-
%telepyth -t 123456789
38-
%telepyth 'Very magic, wow!'
37+
%telepyth -t 123456789
38+
%telepyth 'Very magic, wow!'
3939
```
4040

41+
42+
#### HuggingFace Intergration
43+
44+
TelePyth also provides a [trainer callback][1] for HuggingFace's
45+
`transformers`. There are several usage scenario. The first one is via setting
46+
reporting method in `TrainingArguments`.
47+
48+
```python
49+
import telepyth.interaction
50+
import transformers
51+
52+
args = TrainingArguments(output_dir, report_to=['telepyth'])
53+
```
54+
55+
For more fine-grained control on how and when callback should report metrics,
56+
one can set up callback directly in a list of callbacks.
57+
58+
```python
59+
callback = TelePythCallback(label='finetune', policy='last')
60+
trainer = Trainer(callbacks=[callback])
61+
trainer.train()
62+
```
63+
64+
[1]: https://huggingface.co/docs/transformers/main/en/main_classes/callback
65+
4166
#### TelePyth Client
4267

4368
TelepythClient allows to send notifications, figures and markdown messages
4469
directly without using magics.
4570

4671
```python
47-
from telepyth import TelepythClient
72+
from telepyth import TelepythClient
4873

49-
tp = TelepythClient()
50-
tp.send_text('Hello, World!') # notify with plain text
51-
tp.send_text('_bold text_ and then *italic*') # or with markdown formatted text
52-
tp.send_figure(some_pyplot_figure, 'Awesome caption here!') # or even with figure
74+
tp = TelepythClient()
75+
tp.send_text('Hello, World!') # notify with plain text
76+
tp.send_text('_bold text_ and then *italic*') # or with markdown formatted text
77+
tp.send_figure(some_pyplot_figure, 'Awesome caption here!') # or even with figure
5378
```
5479

5580
#### CLI
5681

5782
TelePyth package also provide command line interface (CLI). It is similar to
5883
IPython magic. For example, one can send notifcation as following.
5984

60-
```bash
61-
telepyth -t 31415926 "Moar notifications!"
85+
```shell
86+
telepyth -t 31415926 "Moar notifications!"
6287
```
6388

6489
#### HTTP API
@@ -68,14 +93,14 @@ wrappers and bindings. This is useful for bash scripting. Just request
6893
TelePyth backend directly to notify user. For instance, to send message from
6994
bash:
7095

71-
```bash
72-
curl https://daskol.xyz/api/notify/<access_token_here> \
73-
-X POST \
74-
-H 'Content-Type: plain/text' \
75-
-d 'Hello, World!'
96+
```shell
97+
curl https://daskol.xyz/api/notify/<access_token_here> \
98+
-X POST \
99+
-H 'Content-Type: plain/text' \
100+
-d 'Hello, World!'
76101
```
77102
See more examples and usage details [here](examples/).
78103

79104
## Credentials
80105

81-
&copy; [Daniel Bershatsky](https://github.com/daskol) <[daniel.bershatsky@skolkovotech.ru](mailto:daniel.berhatsky@skolkovotech.ru)>, 2017
106+
&copy; [Daniel Bershatsky](https://github.com/daskol) <[daniel.bershatsky@skolkovotech.ru](mailto:daniel.berhatsky@skolkovotech.ru)>, 2017-2022

telepyth/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from telepyth.magics import TelePythMagics
1212

1313
if is_huggingface_imported():
14-
from telepyth.huggingface import TelePythCallback
14+
from telepyth.integration import TelePythCallback
1515

1616
__all__ = ('TelePythCallback', 'TelePythClient', 'TelePythMagics',
1717
'TelepythClient')

telepyth/integration/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from telepyth.integration.huggingface import TelePythCallback

0 commit comments

Comments
 (0)