kolibril13 commited on
Commit
cf8f9ea
1 Parent(s): d187414

add content

Browse files
Files changed (6) hide show
  1. .gitignore +162 -0
  2. Dockerfile +21 -0
  3. LICENSE +21 -0
  4. README.md +18 -4
  5. pages/01_app.ipynb +125 -0
  6. requirements.txt +3 -0
.gitignore ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.png
6
+
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # poetry
100
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
104
+ #poetry.lock
105
+
106
+ # pdm
107
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
108
+ #pdm.lock
109
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
110
+ # in version control.
111
+ # https://pdm.fming.dev/#use-with-ide
112
+ .pdm.toml
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
Dockerfile ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM jupyter/base-notebook:4d70cf8da953
2
+
3
+ COPY requirements.txt .
4
+ RUN pip install -r requirements.txt
5
+
6
+ # Install required libraries
7
+ USER root
8
+ RUN apt-get update && apt-get install -y xorg libgomp1
9
+
10
+ RUN mkdir ./pages
11
+ COPY /pages ./pages
12
+
13
+ ENV PROJ_LIB='/opt/conda/share/proj'
14
+
15
+ # Ensure the notebook user has access to the content
16
+ RUN chown -R ${NB_UID} ${HOME}
17
+ USER ${NB_USER}
18
+
19
+ EXPOSE 8765
20
+
21
+ CMD ["solara", "run", "./pages", "--host=0.0.0.0"]
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Jan-Hendrik Müller
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,11 +1,25 @@
1
  ---
2
- title: Molecularnodes Solara
3
- emoji: 🏆
4
- colorFrom: red
5
  colorTo: yellow
6
  sdk: docker
7
  pinned: false
8
  license: mit
 
 
9
  ---
10
 
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Blender with Solara
3
+ emoji: 🌞
4
+ colorFrom: orange
5
  colorTo: yellow
6
  sdk: docker
7
  pinned: false
8
  license: mit
9
+ app_port: 8765
10
+ duplicated_from: giswqs/solara-geospatial
11
  ---
12
 
13
+ ## Introduction
14
+
15
+ A collection of [Solara](https://github.com/widgetti/solara) web apps for geospatial applications
16
+
17
+ Just a proof-of-concept for now. Not all features are working yet. More features will be added in the future.
18
+
19
+ - Web App: <https://giswqs-solara-geospatial.hf.space>
20
+ - GitHub: <https://github.com/opengeos/solara-geospatial>
21
+ - Hugging Face: <https://huggingface.co/spaces/giswqs/solara-geospatial>
22
+
23
+ ## Demos
24
+
25
+ ![](https://i.imgur.com/4uIEnAJ.gif)
pages/01_app.ipynb ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import bpy\n",
10
+ "import tempfile\n",
11
+ "\n",
12
+ "def enable_GPUS():\n",
13
+ " bpy.data.scenes[0].render.engine = \"CYCLES\" #\"CYCLES\"\n",
14
+ " # Set the device_type\n",
15
+ " bpy.context.preferences.addons[\"cycles\"].preferences.compute_device_type = \"METAL\" \n",
16
+ "\n",
17
+ " # Set the device and feature set\n",
18
+ " bpy.context.scene.cycles.device = \"CUDA\" #GPU\n",
19
+ "\n",
20
+ " for scene in bpy.data.scenes:\n",
21
+ " scene.cycles.device = \"GPU\"\n",
22
+ "\n",
23
+ " bpy.context.preferences.addons[\"cycles\"].preferences.get_devices()\n",
24
+ " print(bpy.context.preferences.addons[\"cycles\"].preferences.compute_device_type)\n",
25
+ " for d in bpy.context.preferences.addons[\"cycles\"].preferences.devices:\n",
26
+ " d[\"use\"] = True # Using all devices, include GPU and CPU\n",
27
+ " print(d[\"name\"])\n",
28
+ "\n",
29
+ "def render_image():\n",
30
+ " with tempfile.NamedTemporaryFile(suffix=\".JPEG\", delete=False) as f:\n",
31
+ " bpy.context.scene.render.resolution_y = 200\n",
32
+ " bpy.context.scene.render.resolution_x = 400\n",
33
+ " bpy.context.scene.render.image_settings.file_format = \"JPEG\"\n",
34
+ " bpy.context.scene.render.filepath = f.name\n",
35
+ " # enable_GPUS()\n",
36
+ " bpy.ops.render.render(animation=False, write_still=True)\n",
37
+ " bpy.data.images[\"Render Result\"].save_render(\n",
38
+ " filepath=bpy.context.scene.render.filepath\n",
39
+ " )\n",
40
+ " bpy.app.handlers.render_stats.clear()\n",
41
+ " return f.name\n"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "code",
46
+ "execution_count": null,
47
+ "metadata": {},
48
+ "outputs": [],
49
+ "source": [
50
+ "import solara\n",
51
+ "from IPython.display import Image, display\n",
52
+ "\n",
53
+ "light_position = solara.reactive(3)\n",
54
+ "do_render = solara.reactive(False)\n",
55
+ "\n",
56
+ "@solara.component\n",
57
+ "def Page():\n",
58
+ "\n",
59
+ " def render():\n",
60
+ " if do_render.value:\n",
61
+ " return render_image()\n",
62
+ " \n",
63
+ " result = solara.use_thread(render, [do_render.value])\n",
64
+ " if not do_render.value:\n",
65
+ " solara.Button(\"Start Rendering\", on_click=lambda: do_render.set(True))\n",
66
+ " else:\n",
67
+ " if result.state == solara.ResultState.RUNNING:\n",
68
+ " solara.Info(\"Rendering in progress...\")\n",
69
+ " solara.ProgressLinear()\n",
70
+ " elif result.state == solara.ResultState.ERROR:\n",
71
+ " solara.Error(\"Rendering failed!: %s\" % result.error)\n",
72
+ " elif result.state == solara.ResultState.FINISHED:\n",
73
+ " with solara.Column():\n",
74
+ " solara.Success(\"Rendering complete. \")\n",
75
+ " print(result.value)\n",
76
+ " # workaround for https://github.com/widgetti/solara/pull/267\n",
77
+ " if result.value:\n",
78
+ " solara.Image(result.value)\n",
79
+ "\n",
80
+ "Page()"
81
+ ]
82
+ },
83
+ {
84
+ "cell_type": "code",
85
+ "execution_count": null,
86
+ "metadata": {},
87
+ "outputs": [],
88
+ "source": [
89
+ "import sys\n",
90
+ "import os\n",
91
+ "\n",
92
+ "sys.stdout = open(os.devnull, 'w')\n",
93
+ "sys.stderr = open(os.devnull, 'w')\n"
94
+ ]
95
+ },
96
+ {
97
+ "cell_type": "code",
98
+ "execution_count": null,
99
+ "metadata": {},
100
+ "outputs": [],
101
+ "source": []
102
+ }
103
+ ],
104
+ "metadata": {
105
+ "kernelspec": {
106
+ "display_name": ".venv",
107
+ "language": "python",
108
+ "name": "python3"
109
+ },
110
+ "language_info": {
111
+ "codemirror_mode": {
112
+ "name": "ipython",
113
+ "version": 3
114
+ },
115
+ "file_extension": ".py",
116
+ "mimetype": "text/x-python",
117
+ "name": "python",
118
+ "nbconvert_exporter": "python",
119
+ "pygments_lexer": "ipython3",
120
+ "version": "3.10.13"
121
+ }
122
+ },
123
+ "nbformat": 4,
124
+ "nbformat_minor": 2
125
+ }
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ bpy
2
+ solara
3
+ molecularnodes