Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
developing.html 13.67 KiB
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Developing Persefone · Persefone</title><meta name="title" content="Developing Persefone · Persefone"/><meta property="og:title" content="Developing Persefone · Persefone"/><meta property="twitter:title" content="Developing Persefone · Persefone"/><meta name="description" content="Documentation for Persefone."/><meta property="og:description" content="Documentation for Persefone."/><meta property="twitter:description" content="Documentation for Persefone."/><script data-outdated-warner src="assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="assets/documenter.js"></script><script src="search_index.js"></script><script src="siteinfo.js"></script><script src="../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="index.html"><img src="assets/logo.png" alt="Persefone logo"/></a><div class="docs-package-name"><span class="docs-autofit"><a href="index.html">Persefone</a></span></div><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li><a class="tocitem" href="index.html">Introduction</a></li><li><span class="tocitem">Manual</span><ul><li><a class="tocitem" href="using.html">Usage</a></li><li><a class="tocitem" href="gui.html">Graphical User Interface</a></li><li><a class="tocitem" href="config.html">Configuration</a></li></ul></li><li><span class="tocitem">Developing</span><ul><li class="is-active"><a class="tocitem" href="developing.html">Developing Persefone</a><ul class="internal"><li><a class="tocitem" href="#Workflow"><span>Workflow</span></a></li><li><a class="tocitem" href="#Libraries"><span>Libraries</span></a></li><li><a class="tocitem" href="#Julia-editors"><span>Julia editors</span></a></li></ul></li><li><a class="tocitem" href="adapting.html">Adapting Persefone</a></li><li><a class="tocitem" href="architecture.html">Source code architecture</a></li><li><a class="tocitem" href="gis.html">Maps and weather data</a></li><li><a class="tocitem" href="species-dsl.html">Defining new species</a></li></ul></li><li><span class="tocitem">Core</span><ul><li><a class="tocitem" href="simulation.html">Simulation</a></li><li><a class="tocitem" href="io.html">Input and Output</a></li></ul></li><li><span class="tocitem">Nature</span><ul><li><a class="tocitem" href="nature.html">Nature</a></li><li><a class="tocitem" href="energy.html">Dynamic Energy Budgets</a></li><li><a class="tocitem" href="species.html">Species</a></li></ul></li><li><a class="tocitem" href="crops.html">Crop submodel</a></li><li><a class="tocitem" href="farm.html">Farm submodel</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Developing</a></li><li class="is-active"><a href="developing.html">Developing Persefone</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href="developing.html">Developing Persefone</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://git.idiv.de/persefone/persefone-model" title="View the repository"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">Repository</span></a><a class="docs-navbar-link" href="https://git.idiv.de/persefone/persefone-model/-/tree/master/docs/src/developing.md" title="Edit source"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h1 id="Developing-Persefone"><a class="docs-heading-anchor" href="#Developing-Persefone">Developing Persefone</a><a id="Developing-Persefone-1"></a><a class="docs-heading-anchor-permalink" href="#Developing-Persefone" title="Permalink"></a></h1><h2 id="Workflow"><a class="docs-heading-anchor" href="#Workflow">Workflow</a><a id="Workflow-1"></a><a class="docs-heading-anchor-permalink" href="#Workflow" title="Permalink"></a></h2><ol><li><p>Pull the current version from the master branch on Gitlab:  <a href="https://git.idiv.de/xo30xoqa/persephone">https://git.idiv.de/xo30xoqa/persephone</a>.</p></li><li><p>If you are working on a new feature, create a new branch to avoid breaking the <code>master</code> branch. (The <code>master</code> branch on Github should always be in a runnable and error-free state.)</p></li><li><p>Implement your changes.</p></li><li><p>Run an example simulation and the test suite to make sure everything works without crashing (<code>make run</code> and <code>make test</code> on Linux, or execute <code>run.jl</code> and <code>test/runtests.jl</code> manually.)</p></li><li><p>Commit your work frequently, and try to keep each commit small. Don&#39;t forget to add relevant tests to the test suite.</p></li><li><p>Once your satisfied with your work, do another pull/merge from the <code>master</code> branch in case somebody else changed the branch in the meantime. Then merge your work into <code>master</code> and push to the Gitlab server.</p></li><li><p>Repeat :-)</p></li></ol><p>The Gitlab <a href="https://git.idiv.de/xo30xoqa/persephone/-/boards/373">issue tracker</a> can be used  to create, discuss, and assign tasks, as well as to monitor progress towards milestones/releases.  Once we have a first release, we will start using <a href="https://semver.org/">semantic versioning</a>.</p><h2 id="Libraries"><a class="docs-heading-anchor" href="#Libraries">Libraries</a><a id="Libraries-1"></a><a class="docs-heading-anchor-permalink" href="#Libraries" title="Permalink"></a></h2><h3 id="Agents.jl"><a class="docs-heading-anchor" href="#Agents.jl">Agents.jl</a><a id="Agents.jl-1"></a><a class="docs-heading-anchor-permalink" href="#Agents.jl" title="Permalink"></a></h3><p>Our model uses <a href="https://juliadynamics.github.io/Agents.jl/stable/">Agents.jl</a> as a framework. Their <a href="https://github.com/JuliaDynamics/Agents.jl">repository</a> can be used to inspect the source code or submit bug reports (the authors are quick to respond). Questions can be asked at the  <a href="https://discourse.julialang.org/c/domain/models/21">Julia Discourse forum</a>.</p><p><em>Tutorial on collaborating on Julia packages:  <a href="https://www.matecdev.com/posts/julia-package-collaboration.html">https://www.matecdev.com/posts/julia-package-collaboration.html</a>.</em></p><h3 id="Revise.jl"><a class="docs-heading-anchor" href="#Revise.jl">Revise.jl</a><a id="Revise.jl-1"></a><a class="docs-heading-anchor-permalink" href="#Revise.jl" title="Permalink"></a></h3><p><a href="https://timholy.github.io/Revise.jl/stable/"><code>Revise.jl</code></a> allows one to reload code without restarting the Julia interpreter. Get it with <code>Pkg.add(&quot;Revise&quot;)</code>, then  add <code>using Revise</code> to <code>.julia/config/startup.jl</code> to have it automatically available.</p><h3 id="Test"><a class="docs-heading-anchor" href="#Test">Test</a><a id="Test-1"></a><a class="docs-heading-anchor-permalink" href="#Test" title="Permalink"></a></h3><p>Persefone uses the inbuilt Julia <a href="https://docs.julialang.org/en/v1/stdlib/Test/">testing framework</a>. All new functions should have appropriate tests written for them in the appropriate file in the <code>test</code> directory. (See <a href="https://git.idiv.de/xo30xoqa/persephone/-/blob/master/test/runtests.jl"><code>test/runtests.jl</code></a> for details.) There are three ways to run the test suite: in the terminal, executing <code>make test</code> or <code>cd test; julia runtests.jl</code>; or in the Julia REPL,  <code>Pkg.activate(&quot;.&quot;); Pkg.test()</code>.</p><h3 id="Documenter.jl"><a class="docs-heading-anchor" href="#Documenter.jl">Documenter.jl</a><a id="Documenter.jl-1"></a><a class="docs-heading-anchor-permalink" href="#Documenter.jl" title="Permalink"></a></h3><p>The HTML documentation is generated using <a href="https://documenter.juliadocs.org">Documenter.jl</a>. Therefore, all new functions should have docstrings attached. New files need to be integrated into the relevant documentation source files in <code>docs/src</code>, and if necessary into <a href="https://git.idiv.de/xo30xoqa/persephone/-/blob/master/docs/builddocs.jl"><code>docs/builddocs.jl</code></a>. To build the documentation, run <code>make docs</code>, or <code>cd docs; julia builddocs.jl</code> (if using the latter, don&#39;t forget to update the date and commit in <code>docs/src/index.md</code>).</p><h2 id="Julia-editors"><a class="docs-heading-anchor" href="#Julia-editors">Julia editors</a><a id="Julia-editors-1"></a><a class="docs-heading-anchor-permalink" href="#Julia-editors" title="Permalink"></a></h2><h3 id="Emacs"><a class="docs-heading-anchor" href="#Emacs">Emacs</a><a id="Emacs-1"></a><a class="docs-heading-anchor-permalink" href="#Emacs" title="Permalink"></a></h3><p>There are a couple of addons that make working with Julia much nicer in Emacs:</p><ol><li><p><code>julia-mode</code> gives syntax highlighting. Install with <code>M-x package-install julia-mode</code>.</p></li><li><p><a href="https://github.com/gcv/julia-snail"><code>julia-snail</code></a> provides IDE-like features,  especially a fully-functional REPL and the ability to evaluate code straight from inside a buffer. Note that the installation can be somewhat tricky. You first need to manually install all the dependencies of its dependency <a href="https://github.com/akermu/emacs-libvterm">vterm</a>, then install vterm itself with <code>M-x package-install vterm</code>, <em>before</em> you can do <code>M-x package-install julia-snail</code>. Then add it to your <code>init.el</code> with <code>(require &#39;julia-snail)</code> and <code>(add-hook &#39;julia-mode-hook #&#39;julia-snail-mode)</code>.</p></li><li><p><a href="http://company-mode.github.io/"><code>company-mode</code></a> integrates with Snail to give code  completion. Install with <code>M-x package-install company</code>, then add  <code>(add-hook &#39;julia-mode-hook #&#39;company-mode)</code> and  <code>(global-set-key (kbd &quot;C-&lt;tab&gt;&quot;) &#39;company-complete)</code> to your <code>init.el</code>.</p></li><li><p><a href="https://magit.vc/"><code>magit</code></a> is a great git interface for Emacs. Install with <code>M-x package-install magit</code> and add <code>(global-set-key (kbd &quot;C-x g&quot;) &#39;magit-status)</code> to your <code>init.el</code>.</p></li></ol><h3 id="VSCode"><a class="docs-heading-anchor" href="#VSCode">VSCode</a><a id="VSCode-1"></a><a class="docs-heading-anchor-permalink" href="#VSCode" title="Permalink"></a></h3><p>See <a href="https://www.julia-vscode.org/">here</a>.</p><p><em>TODO: add more detail.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="config.html">« Configuration</a><a class="docs-footer-nextpage" href="adapting.html">Adapting Persefone »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="auto">Automatic (OS)</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.1.2 on <span class="colophon-date" title="Friday 27 October 2023 10:59">Friday 27 October 2023</span>. Using Julia version 1.9.3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>