Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/engine/src/config/experiment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Config {
// TODO: Ask packages for what language execution they require.
let worker_base_config = worker::Config {
spawn: worker::SpawnConfig {
python: false,
python: true,
rust: false,
javascript: true,
},
Expand Down
33 changes: 15 additions & 18 deletions packages/engine/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl WorkerController {

async fn _run(&mut self) -> Result<()> {
// TODO: Rust, JS
// let mut py_handle = self.py.run().await?;
let mut py_handle = self.py.run().await?;
let mut js_handle = self.js.run().await?;

let mut wp_recv = self.worker_pool_comms.take_recv()?;
Expand Down Expand Up @@ -176,23 +176,23 @@ impl WorkerController {
self.worker_pool_comms.confirm_terminate().map_err(|err| Error::from(format!("Failed to send confirmation of terminating workers: {:?}", err)))?;
break;
}
// py_res = &mut py_handle => {
// log::debug!("Python runner finished unexpectedly");
// py_res??;
// // TODO: send termination to js_handle
// js_handle.await??;
// return Ok(());
// }
py_res = &mut py_handle => {
log::debug!("Python runner finished unexpectedly");
py_res??;
// TODO: send termination to js_handle
js_handle.await??;
return Ok(());
}
js_res = &mut js_handle => {
log::debug!("Javascript runner finished unexpectedly: {:?}", js_res);
js_res??;
// TODO: send termination to py_handle
// py_handle.await??;
py_handle.await??;
return Ok(());
}
}
}
// py_handle.await??;
py_handle.await??;
js_handle.await??;
Ok(())
}
Expand Down Expand Up @@ -531,20 +531,17 @@ impl WorkerController {
};

// TODO: Change to `children(3)` after enabling all runners.
debug_assert!(!self.py.spawned());
debug_assert!(!self.rs.spawned());
let (runner_msgs, runner_receivers) = sync.create_children(1);
let mut runner_msgs: Vec<_> = runner_msgs
let (runner_msgs, runner_receivers) = sync.create_children(2);
let runner_msgs: Vec<_> = runner_msgs
.into_iter()
.map(InboundToRunnerMsgPayload::StateSync)
.collect();
// Borrow checker doesn't allow just `runner_msgs[0]`,
// because it would be a partial move.
let js_msg = runner_msgs.remove(0);
let [js_msg, py_msg]: [InboundToRunnerMsgPayload; 2] = runner_msgs.try_into().unwrap();
tokio::try_join!(
self.js.send_if_spawned(sim_id, js_msg),
/* TODO: self.py.send_if_spawned(msg.sim_id, runner_msgs[1]),
* TODO: self.rs.send_if_spawned(msg.sim_id, runner_msgs[2]), */
self.py.send_if_spawned(sim_id, py_msg),
/* TODO: self.rs.send_if_spawned(sim_id, rs_msg), */
)?;
let fut = async move {
let sync = sync; // Capture `sync` in lambda.
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/src/worker/runner/python/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def load_record_batch(mem, schema=None):

# Returns dataset name, dataset contents and whether JSON could be loaded.
def load_dataset(batch_id):
mem = load_shared_mem(shared_buf_from_c_memory(batch_id))
mem = shared_buf_from_c_memory(load_shared_mem(batch_id))
(_, _, header_offset, header_size, _, _, data_offset, data_size) = load_markers(mem)

# The header has the shortname of the dataset
Expand Down
10 changes: 8 additions & 2 deletions packages/engine/src/worker/runner/python/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def pkgs_from_config(config):
return pkgs


def json_from_np(np_utf8):
return json.loads(np_utf8.tobytes().decode('utf-8'))


class PyInit:
def __init__(self, fbs_bytes):
# TODO: Remove `experiment_id` and `worker_index` from fbs,
Expand All @@ -69,7 +73,9 @@ class PyPackage:
def __init__(self, fb):
self.type = fb.Type()
self.name = fb.Name()
self.payload = json.loads(fb.InitPayload().Inner().decode('utf-8'))
# TODO: Instead of using numpy, just replace `Serialized` with
# a string in the flatbuffers file?
self.payload = json_from_np(fb.InitPayload().InnerAsNumpy())


class PyBatchMsg:
Expand All @@ -92,7 +98,7 @@ def __init__(self, sim_id, fb):
self.pkg_id = fb.PackageSid()
self.task_id = fb.TaskId()
self.sync = PyStateInterimSync(fb.Metaversioning())
self.payload = json.loads(fb.Payload().Inner().decode('utf-8'))
self.payload = json_from_np(fb.Payload().InnerAsNumpy())


class PyStateInterimSync:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ objectId: 5c60988f-abb9-4eff-bded-fb8616dc7d93

# Geospatial

The geospatial viewer provides a realtime view of a simulation running inside any geographic area β€” a neighborhood, a city, a country, or the whole world. It's great for visualizing simulations in which agents occupy a position on a map. Take a look at the [City Infection Model](/@hash/city-infection-model-with-vaccine) for an example simulation using the geospatial viewer.
The geospatial viewer provides a realtime view of a simulation running inside any geographic area β€” a neighborhood, a city, a country, or the whole world. It's great for visualizing simulations in which agents occupy a position on a map. Take a look at the [City Infection Model](https://core.hash.ai/@hash/city-infection-model-with-vaccine/stable?view=geo) for an example simulation using the geospatial viewer.
Copy link
Copy Markdown
Contributor

@Alfred-Mountfield Alfred-Mountfield Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the target branch isn't quite up to date on main


![](https://cdn-us1.hash.ai/site/docs/geospatial-viewer.png)

Expand Down