working workers in browser
This commit is contained in:
parent
56116aea2a
commit
715f79c9c0
13 changed files with 343 additions and 28 deletions
|
|
@ -5,8 +5,12 @@
|
|||
<script src="https://code.jquery.com/jquery-latest.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal/js/jquery.terminal.min.js"></script>
|
||||
<link href="https://cdn.jsdelivr.net/npm/jquery.terminal/css/jquery.terminal.min.css" rel="stylesheet"/>
|
||||
<link href="renderedhtml.css" rel="stylesheet"/>
|
||||
<script src="./pyodide_dev.js"></script>
|
||||
<link href="web/renderedhtml.css" rel="stylesheet"/>
|
||||
<script type="text/javascript">
|
||||
// set the pyodide files URL (packages.json, pyodide.asm.data etc)
|
||||
window.languagePluginUrl = 'web/';
|
||||
</script>
|
||||
<script src="./web/pyodide_dev.js"></script>
|
||||
<!--<script src="./raylet.js"></script>-->
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -80,7 +84,7 @@
|
|||
pyodide.runPythonAsync(`
|
||||
import micropip
|
||||
import js
|
||||
wheel_path = js.window.location.protocol + "//" + js.window.location.host + "/ray_web-0.0.1-py3-none-any.whl"
|
||||
wheel_path = js.window.location.protocol + "//" + js.window.location.host + "/web/ray_web-0.0.1-py3-none-any.whl"
|
||||
micropip.install(wheel_path)
|
||||
`).then( () => {
|
||||
term.echo("from ray import ray")
|
||||
|
|
|
|||
|
|
@ -3,9 +3,21 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script src="https://code.jquery.com/jquery-latest.js"></script>
|
||||
<script src="./raylet.js"></script>
|
||||
<script type="text/javascript">
|
||||
// set the pyodide files URL (packages.json, pyodide.asm.data etc)
|
||||
window.languagePluginUrl = 'web/';
|
||||
</script>
|
||||
<script src="./web/pyodide_dev.js"></script>
|
||||
<script src="./web/workterms.js"></script>
|
||||
<script src="./web/raylet.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Clap if you believe in fairies...</h1>
|
||||
<h2 id="status">Status: starting...</h2>
|
||||
<div id="output">
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
</script>
|
||||
</html>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,41 @@
|
|||
|
||||
languagePluginLoader.then(() => {
|
||||
pyodide.loadPackage(["micropip", "cloudpickle"]).then( () =>
|
||||
pyodide.runPython(`
|
||||
pyodide.loadPackage(["micropip", "cloudpickle"]).then( () => {
|
||||
pyodide.runPythonAsync(`
|
||||
import micropip
|
||||
import js
|
||||
wheel_path = js.window.location.protocol + "//" + js.window.location.host + "/ray_web-0.0.1-py3-none-any.whl"
|
||||
micropip.install(wheel_path)
|
||||
wheel_path = js.window.location.protocol + "//" + js.window.location.host + "/web/ray_web-0.0.1-py3-none-any.whl"
|
||||
micropip.install(wheel_path)`)
|
||||
.then(() => { pyodide.runPython(`
|
||||
from ray import ray
|
||||
ray.connect()
|
||||
from ray.web import exec_work
|
||||
`)
|
||||
)
|
||||
})
|
||||
var wsprotocol = "ws:"
|
||||
if (window.location.protocol == "https:") {
|
||||
wsprotocol = "wss:"
|
||||
}
|
||||
var wspath = wsprotocol + "//" + window.location.host + "/api/ws"
|
||||
var c = new WebSocket(wspath)
|
||||
c.onmessage = function(msg) {
|
||||
var workText = workTerms[Math.floor(Math.random() * workTerms.length)];
|
||||
$("#output").append("<p>" + workText + "...</p>")
|
||||
pyodide.globals.torun = msg.data
|
||||
pyodide.runPythonAsync("exec_work(torun)").then((res) => {
|
||||
$("#output").append("<p>Did work! 👏</p>")
|
||||
c.send(res)
|
||||
})
|
||||
}
|
||||
c.onopen = function() {
|
||||
$("#status").text("Status: connected!")
|
||||
c.send(JSON.stringify({
|
||||
status: 2,
|
||||
error_msg: "WebsocketWorker"
|
||||
}))
|
||||
}
|
||||
c.onclose = function() {
|
||||
$("#status").text("Status: disconnected")
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
|||
108
web/workterms.js
Normal file
108
web/workterms.js
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
workTerms = [
|
||||
"Adding Hidden Agendas",
|
||||
"Adjusting Bell Curves",
|
||||
"Aesthesizing Industrial Areas",
|
||||
"Aligning Covariance Matrices",
|
||||
"Applying Feng Shui Shaders",
|
||||
"Applying Theatre Soda Layer",
|
||||
"Asserting Packed Exemplars",
|
||||
"Attempting to Lock Back-Buffer",
|
||||
"Binding Sapling Root System",
|
||||
"Breeding Fauna",
|
||||
"Building Data Trees",
|
||||
"Bureacritizing Bureaucracies",
|
||||
"Calculating Inverse Probability Matrices",
|
||||
"Calculating Llama Expectoration Trajectory",
|
||||
"Calibrating Blue Skies",
|
||||
"Charging Ozone Layer",
|
||||
"Coalescing Cloud Formations",
|
||||
"Cohorting Exemplars",
|
||||
"Collecting Meteor Particles",
|
||||
"Compounding Inert Tessellations",
|
||||
"Compressing Fish Files",
|
||||
"Computing Optimal Bin Packing",
|
||||
"Concatenating Sub-Contractors",
|
||||
"Containing Existential Buffer",
|
||||
"Debarking Ark Ramp",
|
||||
"Debunching Unionized Commercial Services",
|
||||
"Deciding What Message to Display Next",
|
||||
"Decomposing Singular Values",
|
||||
"Decrementing Tectonic Plates",
|
||||
"Deleting Ferry Routes",
|
||||
"Depixelating Inner Mountain Surface Back Faces",
|
||||
"Depositing Slush Funds",
|
||||
"Destabilizing Economic Indicators",
|
||||
"Determining Width of Blast Fronts",
|
||||
"Deunionizing Bulldozers",
|
||||
"Dicing Models",
|
||||
"Diluting Livestock Nutrition Variables",
|
||||
"Downloading Satellite Terrain Data",
|
||||
"Exposing Flash Variables to Streak System",
|
||||
"Extracting Resources",
|
||||
"Factoring Pay Scale",
|
||||
"Fixing Election Outcome Matrix",
|
||||
"Flood-Filling Ground Water",
|
||||
"Flushing Pipe Network",
|
||||
"Gathering Particle Sources",
|
||||
"Generating Jobs",
|
||||
"Gesticulating Mimes",
|
||||
"Graphing Whale Migration",
|
||||
"Hiding Willio Webnet Mask",
|
||||
"Implementing Impeachment Routine",
|
||||
"Increasing Accuracy of RCI Simulators",
|
||||
"Increasing Magmafacation",
|
||||
"Initializing My Sim Tracking Mechanism",
|
||||
"Initializing Rhinoceros Breeding Timetable",
|
||||
"Initializing Robotic Click-Path AI",
|
||||
"Inserting Sublimated Messages",
|
||||
"Integrating Curves",
|
||||
"Integrating Illumination Form Factors",
|
||||
"Integrating Population Graphs",
|
||||
"Iterating Cellular Automata",
|
||||
"Lecturing Errant Subsystems",
|
||||
"Mixing Genetic Pool",
|
||||
"Modeling Object Components",
|
||||
"Mopping Occupant Leaks",
|
||||
"Normalizing Power",
|
||||
"Obfuscating Quigley Matrix",
|
||||
"Overconstraining Dirty Industry Calculations",
|
||||
"Partitioning City Grid Singularities",
|
||||
"Perturbing Matrices",
|
||||
"Pixalating Nude Patch",
|
||||
"Polishing Water Highlights",
|
||||
"Populating Lot Templates",
|
||||
"Preparing Sprites for Random Walks",
|
||||
"Prioritizing Landmarks",
|
||||
"Projecting Law Enforcement Pastry Intake",
|
||||
"Realigning Alternate Time Frames",
|
||||
"Reconfiguring User Mental Processes",
|
||||
"Relaxing Splines",
|
||||
"Removing Road Network Speed Bumps",
|
||||
"Removing Texture Gradients",
|
||||
"Removing Vehicle Avoidance Behavior",
|
||||
"Resolving GUID Conflict",
|
||||
"Reticulating Splines",
|
||||
"Retracting Phong Shader",
|
||||
"Retrieving from Back Store",
|
||||
"Reverse Engineering Image Consultant",
|
||||
"Routing Neural Network Infanstructure",
|
||||
"Scattering Rhino Food Sources",
|
||||
"Scrubbing Terrain",
|
||||
"Searching for Llamas",
|
||||
"Seeding Architecture Simulation Parameters",
|
||||
"Sequencing Particles",
|
||||
"Setting Advisor Moods",
|
||||
"Setting Inner Deity Indicators",
|
||||
"Setting Universal Physical Constants",
|
||||
"Sonically Enhancing Occupant-Free Timber",
|
||||
"Speculating Stock Market Indices",
|
||||
"Splatting Transforms",
|
||||
"Stratifying Ground Layers",
|
||||
"Sub-Sampling Water Data",
|
||||
"Synthesizing Gravity",
|
||||
"Synthesizing Wavelets",
|
||||
"Time-Compressing Simulator Clock",
|
||||
"Unable to Reveal Current Activity",
|
||||
"Weathering Buildings",
|
||||
"Zeroing Crime Network"
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue