Skip to content

SchmidtDSE/josh

Repository files navigation

Josh Simulation Engine

Ecologist-centered tools for easily describing and running agent-based simulations, executable either locally with parallelization or out to distribution across hundreds of machines.

Work in Progress

Purpose

Focused on vegitation, this JVM-based platform allows for fluent modeling of organisms, disturbances, and management interventions. This open source project supports stochastic mechanics and the use of external resources like outside geotiffs or COGs. Using a highly readable domain specific language crafted just for ecologists, Josh makes it easy to quickly describe ecological systems and run those simulations with highly performant computational machinery with minimal fuss in installation. This suite of tools also allows for running simulations in the browser, local performant parallelized execution to take advantage of a single machine's resources, and large scale distributed processing all without changing a single line of code.

Usage

If you have a browser, you can use these tools without any installation required. When you are ready to scale up, this software can execute either directly on your machine, in a containerized environment, or across potentially hundreds of machines.

Web-based usage

Simply send your browser to editor.joshsim.org. There, you can build simulations using the Josh Language all without installing anything new on your machine. Your work is completely private and your simulations never leave your computer unless you ask them to. They run right within your browser! However, when you are ready to push forward, you can either download your work and continue using your local computer or take advantage of our infrastructure to run your simulations across many machines all with the click of a button!

Local usage

The easiest way to get started locally is simply get yourself a copy of open source Java and the latest release of Josh. Then, fire up the command line. Simply write your code to .josh files and execute locally like so:

$ java -jar joshsim.jar run simulation.josh

Simply run the jar without any command specified to get further help documentation. You can also specify an output location

$ java -jar joshsim.jar run simulation.josh --dump-state state.avro

This will dump the state at each timestep in Avro though, if only the final timestep is required, add the --final-only flag.

Local UI

You can run the local UI through joshsim-server. Simply execute:

$ java -jar joshsim-server.jar

This will start a local web server which makes the UI available via your browser where you can work in private.

Containerized usage

Containerization through Docker and Development Containers can help you move your work from one computer to the next with ease. Please see our Dockerfile and devcontainer.json.

Distributed usage

Distributing workloads is easy. Simply deploy either our jar file or container to a serverless solution like Labmda / CloudRun or submit on your own cluster via Kubernetes. You can send the Josh jar over the network to get your script and you can write to cloud storage. All you have to do is provide the command line arguments:

$ java -jar joshsim.jar run https://your-url.org/script.josh --http-basic-user USERNAME --http=-basic-pass PASSWORD --simulation TestSimulation --replicates 10 --output minio://your-s3-bucket/test_simulation.avro --minio-key ACCESS_KEY --minio-secret ACCESS_SECRET

More details to follow here.

Developing

We have options available for different kinds of development workflows.

Development container

We provide a standard Dockerfile and devcontainer.json. Replit files are also provided (.replit and replit.nix).

Manual environment setup

In addition to a development container we provide instructions for general local setup to aid various environments.

This will produce your home-built copy of Josh at build/libs/joshsim-fat.jar. If you want to develop for the web interface, the following are also required:

  • Install node and npm
  • Install node development dependencies with cd web; npm install --dev
  • Install vanilla JS production dependencies with cd web; bash support/install_deps.sh

Note that test runners do require an available copy of Chrome or Chromium.

Development standards

For Josh itself, please use the Google Java Style Guide. We aim for approximately 80% test coverage and all non-test public members having JavaDoc.

For the web interface, please use the Google JavaScript Style Guide with all non-test public members having JSDoc. Note that we use vanilla JavaScript which must be able to run directly in browser so code is not run through webpack or similar prior to deployment. Very limited production dependencies are simply included via minified JS. We do not consider production use of CDNs to be acceptable for privacy reasons.

We require that our automated tests and checks pass prior to merging commits.

Testing

We offer tests at two levels. First, the Java source behind Josh can be tested via JUnit and Gradle:

$ gradle test

Josh scripts can also be validated for syntax errors and tested if unit tests are provided:

$ java -jar joshsim.jar validate script.josh
$ java -jar joshsim.jar test script.josh

To check the default examples, execute bash examples/validate.sh and bash examples/test.sh. Finally, front-end tests for the editor can run via grunt:

$ grunt

This requires a node setup.

Deployment

Deployment instructions are provided both inside and outside of CI / CD.

Automated deployment

To deploy a new version of Josh, simply merge to main to generate and deploy a new joshsim.jar, joshsim-server.jar, and web editor resources (including joshsim.wasm) via SFTP and GitHub Actions.

Manual deployment

If deploying outside of our CI / CD systems, only the jar is required to run Josh.

$ gradle fatJar

Simply use the output found under build/libs/joshsim-fat.jar. If also deploying the web editor:

$ cd web; bash support/package.sh

Simply serve static files from web/build like so:

$ cd web/build; python -m http.server

Any static hosting solution such as Nginx or Jetty can be used.

Open source

This is an open source project of the Schmidt Center for Data Science and Environment at UC Berkeley.

Licensing

Released under the BSD-3-Clause License. See LICENSE for more information.

Technologies used

We use the following open source technologies:

Also uses Tumerin.

About

Specification for the Josh language specification.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages