Skip to content

Commit

Permalink
Tune for Google Collab
Browse files Browse the repository at this point in the history
anayden committed Jan 17, 2024
1 parent 2b45fad commit 2a1b4c8
Showing 2 changed files with 15 additions and 29 deletions.
19 changes: 5 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,24 +2,20 @@

[![PyPI](https://img.shields.io/pypi/v/r2dt-client.svg)][pypi_]
[![Status](https://img.shields.io/pypi/status/r2dt-client.svg)][status]
[![Python Version](https://img.shields.io/pypi/pyversions/r2dt-client)][python version]
![Static Badge](https://img.shields.io/badge/Python_version-3.9%2B-blue)

[![License](https://img.shields.io/pypi/l/r2dt-client)][license]

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)][pre-commit]
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)][black]

[pypi_]: https://pypi.org/project/r2dt-client/
[status]: https://pypi.org/project/r2dt-client/
[python version]: https://pypi.org/project/r2dt-client
[read the docs]: https://r2dt-client.readthedocs.io/
[tests]: https://github.com/anayden/r2dt-client/actions?workflow=Tests
[codecov]: https://app.codecov.io/gh/anayden/r2dt-client
[pre-commit]: https://github.com/pre-commit/pre-commit
[black]: https://github.com/psf/black
[CI]: https://github.com/anayden/r2dt-client/actions

## Features

- TODO
- Access to the [R2DT] API via Python
- Display R2DT widget in Jupyter Notebook

## Requirements

@@ -66,11 +62,6 @@ draw(
">S box leader))\nCTCTTATCGAGAGTTGGGCGAGGGATTTGGCCTTTTGACCCCAAAAGCAACCGACCGTAATTCCATTGTGAAATGGGGCGCATTTTTTTCGCGCCGAGACGCTGGTCTCTTAAGGCACGGTGCTAATTCCATTCAGATCTGATCTGAGAGATAAGAG")
```

## Contributing

Contributions are very welcome.
To learn more, see the [Contributor Guide].

## License

Distributed under the terms of the [MIT license][license],
25 changes: 10 additions & 15 deletions src/r2dt_client/widgets/widget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import threading
import time

from IPython.display import clear_output # type: ignore
@@ -8,6 +7,7 @@
from r2dt_client import fetch_results_for
from r2dt_client import submit
from r2dt_client import update_status_for
from r2dt_client.entities import Format


def _display_spinner() -> ValueWidget:
@@ -36,17 +36,12 @@ def draw(sequence: str) -> None:
spinner = _display_spinner()
start_time = time.time()

def job_monitor():
while not job.done:
time.sleep(2)
update_status_for(job)
elapsed_time = int(time.time() - start_time)
_update_spinner(spinner, elapsed_time)
fetch_results_for(job)
svg_content = job.results["svg"]
clear_output(wait=True) # Clear the spinner
_display_svg(svg_content)

# Run the monitoring in a separate thread, so it doesn't block the notebook
thread = threading.Thread(target=job_monitor)
thread.start()
while not job.done:
time.sleep(2)
update_status_for(job)
elapsed_time = int(time.time() - start_time)
_update_spinner(spinner, elapsed_time)
fetch_results_for(job)
svg_content = job.results[Format.svg]
clear_output(wait=True) # Clear the spinner
_display_svg(svg_content)

0 comments on commit 2a1b4c8

Please sign in to comment.