Skip to content

Commit

Permalink
chore: Separate into proper python package. #1796
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Jan 18, 2023
1 parent f845ba1 commit fc6f3ff
Show file tree
Hide file tree
Showing 13 changed files with 142 additions and 16 deletions.
14 changes: 7 additions & 7 deletions py/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ all: build ## Build h2o_wave wheel

.PHONY: build
build: purge
# H2O_WAVE_BUILD_OS=windows ./venv/bin/python3 setup.py bdist_wheel --plat-name=win_amd64
# H2O_WAVE_BUILD_OS=linux ./venv/bin/python3 setup.py bdist_wheel --plat-name=manylinux1_x86_64
# H2O_WAVE_BUILD_OS=darwin ./venv/bin/python3 setup.py bdist_wheel --plat-name=macosx_10_9_x86_64
# H2O_WAVE_BUILD_OS=darwin H2O_WAVE_BUILD_ARCH=arm64 ./venv/bin/python3 setup.py bdist_wheel --plat-name=macosx_11_0_arm64
# H2O_WAVE_BUILD_OS=darwin H2O_WAVE_BUILD_ARCH=arm64 ./venv/bin/python3 setup.py bdist_wheel --plat-name=macosx_12_0_arm64
# H2O_WAVE_BUILD_OS=any ./venv/bin/python3 setup.py bdist_wheel
./venv/bin/python3 setup_wavelite.py bdist_wheel
H2O_WAVE_BUILD_OS=windows ./venv/bin/python3 setup.py bdist_wheel --plat-name=win_amd64
H2O_WAVE_BUILD_OS=linux ./venv/bin/python3 setup.py bdist_wheel --plat-name=manylinux1_x86_64
H2O_WAVE_BUILD_OS=darwin ./venv/bin/python3 setup.py bdist_wheel --plat-name=macosx_10_9_x86_64
H2O_WAVE_BUILD_OS=darwin H2O_WAVE_BUILD_ARCH=arm64 ./venv/bin/python3 setup.py bdist_wheel --plat-name=macosx_11_0_arm64
H2O_WAVE_BUILD_OS=darwin H2O_WAVE_BUILD_ARCH=arm64 ./venv/bin/python3 setup.py bdist_wheel --plat-name=macosx_12_0_arm64
H2O_WAVE_BUILD_OS=any ./venv/bin/python3 setup.py bdist_wheel
./venv/bin/python3 h2o_wavelite/setup.py bdist_wheel

setup: ## Install dependencies
git clone --depth 1 --branch $(WAVE_ML_VERSION) https://github.com/h2oai/wave-ml.git h2o_wave_ml
Expand Down
59 changes: 59 additions & 0 deletions py/h2o_wavelite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
H2O Wave
========

H2O Wave is a lightweight software stack for programming interactive web applications
entirely in Python (no HTML/Javascript/CSS required).

It is designed to make it fast, fun and easy to build low-latency, realtime,
collaborative, web-based applications. It ships batteries-included with
a suite of form and data visualization components for rapidly prototyping
analytical and decision-support applications.

Wave's components work in conjunction with the Wave relay server that facilitates
realtime state synchronization between Python and web browsers.

Installing
----------

Install and update using conda

```bash
conda config --append channels conda-forge
conda install -c h2oai h2o-wave
```

Hello world
-----------

`hello.py`:

```bash
from h2o_wave import site, ui

# Access the web page at http://localhost:10101/demo
page = site['/demo']

# Add some content.
page['example'] = ui.markdown_card(
box='1 1 2 2',
title='Hello World!',
content='And now for something completely different.',
)

# Save the page
page.save()
```

Run `hello.py`:

```bash
python hello.py
```

Links
-----

- Website: [https://wave.h2o.ai/](https://wave.h2o.ai/)
- Releases: [https://pypi.org/project/h2o-wave/](https://pypi.org/project/h2o-wave/)
- Code: [https://github.com/h2oai/wave](https://github.com/h2oai/wave)
- Issue tracker: [https://github.com/h2oai/wave/issues](https://github.com/h2oai/wave/issues)
64 changes: 64 additions & 0 deletions py/h2o_wavelite/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
H2O Wave
========

H2O Wave is a lightweight software stack for programming interactive web applications
entirely in Python (no HTML/Javascript/CSS required).

It is designed to make it fast, fun and easy to build low-latency, realtime,
collaborative, web-based applications. It ships batteries-included with
a suite of form and data visualization components for rapidly prototyping
analytical and decision-support applications.

Wave's components work in conjunction with the Wave relay server that facilitates
realtime state synchronization between Python and web browsers.


Installing
----------

Install and update using `pip`_:

.. code-block:: text
pip install -U h2o-wave
Hello world
----------------

``hello.py``:

.. code-block:: python
from h2o_wave import site, ui
# Access the web page at http://localhost:10101/demo
page = site['/demo']
# Add some content.
page['example'] = ui.markdown_card(
box='1 1 2 2',
title='Hello World!',
content='And now for something completely different.',
)
# Save the page
page.save()
Run ``hello.py``:

.. code-block:: text
$ python hello.py
Links
-----

* Website: https://wave.h2o.ai/
* Releases: https://pypi.org/project/h2o-wave/
* Code: https://github.com/h2oai/wave
* Issue tracker: https://github.com/h2oai/wave/issues

.. _pip: https://pip.pypa.io/en/stable/quickstart/

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ async def _run(self):
await self._process({})

# Event loop.
while True:
data = await self._recv()
try:
try:
while True:
data = await self._recv()
data = await _parse_msg(data)
data = json.loads(data)
except json.JSONDecodeError:
raise ValueError('Invalid message')
await self._process(data)
await self._process(data)
except json.JSONDecodeError:
print('Wave Error: Invalid message.')

async def _process(self, args: dict):
app_state, user_state, client_state = self._state
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 6 additions & 3 deletions py/setup_wavelite.py → py/h2o_wavelite/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@
import os
from pathlib import Path

with open('README.rst', 'r') as readme:
curr_dir_path = os.path.dirname(os.path.realpath(__file__))

with open(os.path.join(curr_dir_path, 'README.rst'), 'r') as readme:
long_description = readme.read()

with open('README.md', 'r') as readme_markdown:
with open(os.path.join(curr_dir_path, 'README.md'), 'r') as readme_markdown:
conda_description = readme_markdown.read()

version = os.getenv('VERSION', 'DEV')


def get_data_files():
data_dict = {}

build_path = os.path.join('..', 'ui', 'build')
build_path = os.path.join(curr_dir_path, '..', '..', 'ui', 'build')
for p in Path(build_path).rglob('*'):
if os.path.isdir(p):
continue
Expand Down

0 comments on commit fc6f3ff

Please sign in to comment.