Skip to content

Commit

Permalink
chore: Apply linting throughout project (#137)
Browse files Browse the repository at this point in the history
* Apply linting throughout project

* Fix typo

* Add pre-commit Ruff and Prettier

* Fix CI issues
  • Loading branch information
gjmooney authored Feb 6, 2024
1 parent 7f6bf70 commit 5685957
Show file tree
Hide file tree
Showing 33 changed files with 2,178 additions and 1,882 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: code-quality

on:
pull_request:
push:
branches: [main]

defaults:
run:
shell: bash -l {0}

jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@main
with:
environment-name: ipywebrtc-dev
environment-file: dev_environment.yml
python-version: ${{ matrix.python-version }}
mamba-version: "*"
auto-activate-base: false
channels: conda-forge

- name: Install dependencies
run: |
pip install ".[dev]"
pre-commit install
- name: run pre-commit
run: |
pre-commit run --all-files
145 changes: 70 additions & 75 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Tests
on:
push:
branches:
- master
- master
pull_request:
branches:
- master
- master

defaults:
run:
Expand All @@ -23,78 +23,74 @@ jobs:
python-version: [3.9]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@main
with:
environment-name: ipywebrtc-dev
environment-file: dev_environment.yml
python-version: ${{ matrix.python-version }}
mamba-version: "*"
auto-activate-base: false
channels: conda-forge

- name: Test flake8
run: flake8 ipywebrtc --ignore=E501,F405

- name: Install ipywebrtc
run: pip install .

- name: Check installation files
run: |
test -d $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-webrtc
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-webrtc/extension.js
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-webrtc/index.js
test -d $CONDA_PREFIX/share/jupyter/labextensions/jupyter-webrtc
test -f $CONDA_PREFIX/share/jupyter/labextensions/jupyter-webrtc/package.json
- name: Check nbextension and labextension
run: |
jupyter nbextension list 2>&1 | grep -ie "jupyter-webrtc/extension.*enabled" -
jupyter labextension list 2>&1 | grep -ie "jupyter-webrtc.*enabled.*ok" -
- name: Run js tests
run: |
npm install
npm run test
working-directory: js

- name: Build docs (Only on MacOS for build speed)
if: matrix.os == 'macos-latest'
run: |
cd docs/source/
sphinx-build . _build/html
cd ../..
- name: Checkout
uses: actions/checkout@v2

- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@main
with:
environment-name: ipywebrtc-dev
environment-file: dev_environment.yml
python-version: ${{ matrix.python-version }}
mamba-version: "*"
auto-activate-base: false
channels: conda-forge

- name: Install ipywebrtc
run: pip install .

- name: Check installation files
run: |
test -d $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-webrtc
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-webrtc/extension.js
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-webrtc/index.js
test -d $CONDA_PREFIX/share/jupyter/labextensions/jupyter-webrtc
test -f $CONDA_PREFIX/share/jupyter/labextensions/jupyter-webrtc/package.json
- name: Check nbextension and labextension
run: |
jupyter nbextension list 2>&1 | grep -ie "jupyter-webrtc/extension.*enabled" -
jupyter labextension list 2>&1 | grep -ie "jupyter-webrtc.*enabled.*ok" -
- name: Run js tests
run: |
npm install
npm run test
working-directory: js

- name: Build docs (Only on MacOS for build speed)
if: matrix.os == 'macos-latest'
run: |
cd docs/source/
sphinx-build . _build/html
cd ../..
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@main
with:
environment-name: ipywebrtc-dev
environment-file: dev_environment.yml
python-version: ${{ matrix.python-version }}
mamba-version: "*"
auto-activate-base: false
channels: conda-forge

- name: Checkout
uses: actions/checkout@v2

- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@main
with:
environment-name: ipywebrtc-dev
environment-file: dev_environment.yml
python-version: ${{ matrix.python-version }}
mamba-version: "*"
auto-activate-base: false
channels: conda-forge

- name: Build packages
run: |
python setup.py sdist bdist_wheel
cd dist
sha256sum * | tee SHA256SUMS
- name: Upload builds
uses: actions/upload-artifact@v2
with:
name: dist ${{ github.run_number }}
path: ./dist
- name: Build packages
run: |
python setup.py sdist bdist_wheel
cd dist
sha256sum * | tee SHA256SUMS
- name: Upload builds
uses: actions/upload-artifact@v2
with:
name: dist ${{ github.run_number }}
path: ./dist

install:
runs-on: ${{ matrix.os }}-latest
Expand All @@ -104,15 +100,14 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python: ['3.6', '3.9']
python: ["3.6", "3.9"]
include:
- python: '3.6'
dist: 'ipywebrtc*.tar.gz'
- python: '3.9'
dist: 'ipywebrtc*.whl'
- python: "3.6"
dist: "ipywebrtc*.tar.gz"
- python: "3.9"
dist: "ipywebrtc*.whl"

steps:

- name: Checkout
uses: actions/checkout@v2

Expand Down
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: "https://github.com/pre-commit/mirrors-prettier"
rev: "v3.1.0"
hooks:
- id: prettier
types: [javascript]
stages: [commit]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.1.9"
hooks:
- id: ruff
stages: [commit]
- id: ruff-format
stages: [commit]
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
**/node_modules
**/lib
**/package.json
48 changes: 29 additions & 19 deletions .releash.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
from releash import *
import glob

from releash import *

# these objects only tag when they are exe
gitpush = ReleaseTargetGitPush()


filenames_python = glob.glob('*')
filenames_python.remove('js')
filenames_python = glob.glob("*")
filenames_python.remove("js")
# filenames_python.remove('notebooks')
package_python = add_package(".", "py", distribution_name='ipywebrtc', filenames=filenames_python)
package_python = add_package(".", "py", distribution_name="ipywebrtc", filenames=filenames_python)

version_python = VersionSource(package_python, '{path}/ipywebrtc/_version.py')
version_python = VersionSource(package_python, "{path}/ipywebrtc/_version.py")
gittag = ReleaseTargetGitTagVersion(version_source=version_python)

package_python.version_source = version_python
package_python.version_targets.append(VersionTarget(package_python, '{path}/ipywebrtc/_version.py'))
package_python.version_targets.append(VersionTarget(package_python, "{path}/ipywebrtc/_version.py"))

package_python.release_targets.append(gittag)
package_python.release_targets.append(ReleaseTargetSourceDist(package_python))
#core.release_targets.append(gitpush)
#package_python.release_targets.append(ReleaseTargetCondaForge(package_python, '../feedstocks/ipywebrtc-feedstock'))
# core.release_targets.append(gitpush)
# package_python.release_targets.append(ReleaseTargetCondaForge(package_python, '../feedstocks/ipywebrtc-feedstock'))


# js part
package_js = add_package("js", "js", distribution_name='ipywebrtc')
package_js = add_package("js", "js", distribution_name="ipywebrtc")

version_js = VersionSource(package_js, '{path}/../ipywebrtc/_version.py', tuple_variable_name='__version_tuple_js__')
version_js = VersionSource(
package_js,
"{path}/../ipywebrtc/_version.py",
tuple_variable_name="__version_tuple_js__",
)

package_js.version_source = version_js
package_js.version_targets.append(VersionTarget(package_js, '{path}/../ipywebrtc/_version.py',
tuple_variable_name='__version_tuple_js__',
string_variable_name='__version_js__'))
package_js.version_targets.append(VersionTargetJson(package_js, '{path}/package.json'))

gittag_js = ReleaseTargetGitTagVersion(version_source=version_js, postfix='_js')
package_js.version_targets.append(
VersionTarget(
package_js,
"{path}/../ipywebrtc/_version.py",
tuple_variable_name="__version_tuple_js__",
string_variable_name="__version_js__",
)
)
package_js.version_targets.append(VersionTargetJson(package_js, "{path}/package.json"))

gittag_js = ReleaseTargetGitTagVersion(version_source=version_js, postfix="_js")
package_js.release_targets.append(gittag_js)
package_js.release_targets.append(ReleaseTargetNpm(package_js))
#core.release_targets.append(gitpush)
#package_python.release_targets.append(ReleaseTargetCondaForge(package_python, '../feedstocks/ipyvolume-feedstock'))

# core.release_targets.append(gitpush)
# package_python.release_targets.append(ReleaseTargetCondaForge(package_python, '../feedstocks/ipyvolume-feedstock'))
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,46 @@ WebRTC and MediaStream API exposed in the Jupyter notebook/lab.

[See this tweet](https://twitter.com/maartenbreddels/status/1027995865024262144) for a demo screencast.


# Why use ipywebrtc?

Using ipywebrtc you can create a [MediaStream](api.html#ipywebrtc.webrtc.MediaStream) out of:
* [Any ipywidget](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.WidgetStream).
* A [video](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.VideoStream) file.
* An [image](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.ImageStream) file.
* An [audio](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.AudioStream) file.
* Your [webcam/camera](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.CameraStream).

From this MediaStream you can:
- [Any ipywidget](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.WidgetStream).
- A [video](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.VideoStream) file.
- An [image](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.ImageStream) file.
- An [audio](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.AudioStream) file.
- Your [webcam/camera](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.CameraStream).

* [Record a movie](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.VideoRecorder).
* [Record an image snapshot](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.ImageRecorder).
* [Record an audio fragment](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.AudioRecorder).
* Stream it to peers using the simple [chat function](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.chat)
* [Use it as a texture in ipyvolume](https://twitter.com/maartenbreddels/status/894983501996584961)
From this MediaStream you can:

- [Record a movie](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.VideoRecorder).
- [Record an image snapshot](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.ImageRecorder).
- [Record an audio fragment](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.webrtc.AudioRecorder).
- Stream it to peers using the simple [chat function](https://ipywebrtc.readthedocs.io/en/latest/api.html#ipywebrtc.chat)
- [Use it as a texture in ipyvolume](https://twitter.com/maartenbreddels/status/894983501996584961)

# Demos

## WebRTC and [ipyvolume](https://github.com/maartenbreddels/ipyvolume/)

Use remote MediaStreams and show them in 3d using [ipyvolume](https://github.com/maartenbreddels/ipyvolume/).

![webrtc](https://user-images.githubusercontent.com/1765949/43977008-03dbfac0-9ce3-11e8-9bb9-4a5f8f2cc79a.gif)

## ImageRecorder

Record and image from *any* stream for postprocessing.
Record and image from _any_ stream for postprocessing.

![recorder](https://user-images.githubusercontent.com/1765949/43978560-fe0bf500-9ce7-11e8-81b9-9d30d26d7492.gif)

## WidgetStream

Turn *any* widget into a MediaStream.
Turn _any_ widget into a MediaStream.

![widget-stream](https://user-images.githubusercontent.com/1765949/43977992-1668d534-9ce6-11e8-8fab-783105476e98.gif)

# Installation


To install:

```
Expand Down
7 changes: 4 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
- To release a new version of ipywebrtc on PyPI:

Update _version.py (set release version, remove 'dev')
Update \_version.py (set release version, remove 'dev')
git add and git commit
python setup.py sdist upload
python setup.py bdist_wheel upload
git tag -a X.X.X -m 'comment'
Update _version.py (add 'dev' and increment minor)
Update \_version.py (add 'dev' and increment minor)
git add and git commit
git push
git push --tags

- To release a new version of jupyter-webrtc on NPM:

# nuke the `dist` and `node_modules`
# nuke the `dist` and `node_modules`

git clean -fdx
npm install
npm publish
Loading

0 comments on commit 5685957

Please sign in to comment.