acturtle / cashflower

An open-source Python framework for actuarial cash flow models
https://cashflower.acturtle.com
MIT License
38 stars 9 forks source link

Run chosen model points with a command #319

Closed zchmielewska closed 11 months ago

zchmielewska commented 11 months ago

For various checks or debugging purposes, it's common to run the model for a single or a subset model points.

We can do that by manipulating the input.py script. But maybe it would be handy to have a dedicated command for it too.

Now we have only dedicated command for running a specific version:

python run.py 2 

will run the 2nd version of the runplan.

What could be nice is to have:

python run.py --version 2 --id  374164

Runs 2nd version of the runplan for model point 374164.

python run.py -i [374164, 536473]

Runs the base version (1st version of the runplan) for model points 374164 and 536473.

zchmielewska commented 11 months ago
import argparse

def main():
    parser = argparse.ArgumentParser(description="Your script description")
    parser.add_argument("--version", type=int, help="Specify the version")
    parser.add_argument("--id", type=int, help="Specify the ID")

    args = parser.parse_args()

    if args.version is not None:
        version = args.version
        # You can use the 'version' variable in your code
        print(f"Version: {version}")

    if args.id is not None:
        id_value = args.id
        # You can use the 'id_value' variable in your code
        print(f"ID: {id_value}")

if __name__ == "__main__":
    main()
zchmielewska commented 11 months ago

I did it only for a single model point id as this is the main point if this feature.

If we find it helpful to also have a list of ids (two or three model points) this can be implemented in the future.

Corresponding PR: 9e1fbc7bdc00e9dce724406d987947fec0cb127d