Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Programmatic FLEE Execution #102

Closed
wants to merge 11 commits into from

Conversation

nicleosch
Copy link

@nicleosch nicleosch commented Dec 21, 2023

Preliminary Information

  • This pull request originates from collaborative efforts between students from the Technical University of Munich and the World Food Programme (WFP). The objective is to forecast the movements of Internally Displaced Persons (IDPs).

Summary

This pull request introduces a new module, runner.py, containing a class, Simulation, that allows flee execution via function calls extending the previously used command line interface. The goal is to provide developers with a programmatic way to interact with flee within their applications.

Changes Made

  • Added a new module: runner.py
  • Implemented functions for flee invocation, providing a more flexible and modular approach
  • Refactored existing code to accommodate the new module and enhance maintainability
  • Instead of writing a file, the output is a python dictionary containing the simulation results
  • The simulation results includes refugees/IDPs at every location, providing valuable insights beyond camp-specific data

How to Use

Developers can now utilize the runner.py module in their codebase to programmatically invoke the tool. Example usage:

from runscripts.runner import Simulation

# Create an instance of the Simulation class
sim = Simulation(input_dir, validation_dir, duration, simsettings)

# Invoke flee using the function call
output = sim.run()

# Process the output as needed

Benefits

  • Easier integration of flee into existing codebases
  • Improved flexibility for developers to customize flee invocation

Testing

  • Unit tests cover various scenarios, including edge cases and typical usage patterns.
  • feel free to write additional tests

Reviewer Checklist

  • Verify the correctness of the new module and its functions.
  • Check for adherence to coding standards and best practices.
  • Review test coverage and ensure appropriate testing scenarios.

@djgroen
Copy link
Owner

djgroen commented Jan 1, 2024

Okay. Overall I think this is a sensible change, although the contents of runner.py does overlap strongly with those of run.py and run_par.py, which are already widely used.

This is not a serious issue, but it just means that whenever we update the run functions, we will have to update this now in three places, not two, to prevent things from breaking.

Also, I think it would be good to mention this new functionality somewhere in the docs/ documentation. Perhaps it's worth adding that?

Lastly, I see that some of the tests are failing, but if they work then I'm happy to merge this in.

@@ -0,0 +1,146 @@
from flee import flee, spawning
from flee.datamanager import handle_refugee_data, read_period
from flee.datamanager import DataTable #DataTable.subtract_dates()

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'DataTable' is not used.
from flee.datamanager import handle_refugee_data, read_period
from flee.datamanager import DataTable #DataTable.subtract_dates()
from flee import InputGeography
import numpy as np

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'np' is not used.
from flee.datamanager import DataTable #DataTable.subtract_dates()
from flee import InputGeography
import numpy as np
import flee.postprocessing.analysis as a

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'a' is not used.
@nicleosch nicleosch closed this Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants