{"id":23050440,"url":"https://github.com/musically-ut/decorated_options","last_synced_at":"2025-08-15T03:31:28.245Z","repository":{"id":62567317,"uuid":"64085064","full_name":"musically-ut/decorated_options","owner":"musically-ut","description":"Make long argument lists saner with decoration.","archived":false,"fork":false,"pushed_at":"2018-03-15T19:35:54.000Z","size":17,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-15T11:05:00.542Z","etag":null,"topics":["decorators","python","python-3","python-library"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/musically-ut.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-24T20:51:11.000Z","updated_at":"2023-07-25T14:03:02.000Z","dependencies_parsed_at":"2022-11-03T19:06:22.325Z","dependency_job_id":null,"html_url":"https://github.com/musically-ut/decorated_options","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musically-ut%2Fdecorated_options","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musically-ut%2Fdecorated_options/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musically-ut%2Fdecorated_options/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musically-ut%2Fdecorated_options/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/musically-ut","download_url":"https://codeload.github.com/musically-ut/decorated_options/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229890135,"owners_count":18140041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decorators","python","python-3","python-library"],"created_at":"2024-12-15T23:32:48.697Z","updated_at":"2024-12-15T23:32:49.264Z","avatar_url":"https://github.com/musically-ut.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"========\nOverview\n========\n\n.. start-badges\n\n.. list-table::\n    :stub-columns: 1\n\n    * - tests\n      - |build|\n    * - package\n      - |version| |wheel| |supported-versions| |supported-implementations|\n      \n.. |build| image:: https://travis-ci.org/musically-ut/decorated_options.svg?branch=master\n    :target: https://travis-ci.org/musically-ut/decorated_options\n\n.. |docs| image:: https://readthedocs.org/projects/decorated_options/badge/?style=flat\n    :target: https://readthedocs.org/projects/decorated_options\n    :alt: Documentation Status\n\n.. |version| image:: https://img.shields.io/pypi/v/decorated_options.svg?style=flat\n    :alt: PyPI Package latest release\n    :target: https://pypi.python.org/pypi/decorated_options\n\n.. |wheel| image:: https://img.shields.io/pypi/wheel/decorated_options.svg?style=flat\n    :alt: PyPI Wheel\n    :target: https://pypi.python.org/pypi/decorated_options\n\n.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/decorated_options.svg?style=flat\n    :alt: Supported versions\n    :target: https://pypi.python.org/pypi/decorated_options\n\n.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/decorated_options.svg?style=flat\n    :alt: Supported implementations\n    :target: https://pypi.python.org/pypi/decorated_options\n\n\n.. end-badges\n\nFunction decorator to make argument passing saner.\n\nI often have to write a function which runs a simulation/learning task which I\nneed to run for several different parameters. This initially is manageable, but\nthen slowly configuration creep starts to happen: I keep adding more and more\nparameters to the functions which run the simulations and keep making my old\ncode more and more fragile.\n\nI wrote ``decorated_options`` to decouple the arguments for different set of experiments.\n\nIn brief,  ``decorated_options`` converts this:\n\n.. code:: python\n\n    def run(max_num_followers, num_segments, is_hawkes):\n        # ...\n        # ...\n\n    # tmp = run_multiple_followers(max_num_followers=10, num_segments=10, is_hawkes=True)\n    # tmp = run_multiple_followers(max_num_followers=100, num_segments=10, is_hawkes=False)\n    # tmp = run_multiple_followers(max_num_followers=10, num_segments=50, is_hawkes=True)\n    tmp = run_multiple_followers(max_num_followers=1000, num_segments=100, is_hawkes=False)\n\n\nto:\n\n.. code:: python\n\n    from decorated_options import Options, optioned\n\n    @optioned('opts')\n    def run(max_num_followers, num_segments, is_hawkes):\n        # ...\n        # ...\n\n\n    opts = Options(max_num_followers=10, num_segments=10, is_hawkes=True)\n    # tmp = run_multiple_followers(opts=opts)\n    # tmp = run_multiple_followers(max_num_followers=100, is_hawkes=False, opts=opts)\n    # tmp = run_multiple_followers(num_segments=50, is_hawkes=False, opts=opts)\n    tmp = run_multiple_followers(max_num_followers=1000, num_segments=100, is_hawkes=False)\n\n\n\n* Benefits over ``**kwargs`` in receiving function:\n\n  1. Early reporting of errors at call-time.\n  2. No need to unpack the values.\n  3. Default values do not have to be hard-coded.\n  4. Allows progressive improvement, no need to change old code which uses positional arguments.\n\n* Benefits over ``**dict`` while calling:\n\n  1. Easier updating/overriding of values\n  2. Positional arguments also work\n  3. Guaranteed immutability (throws Exceptions on attempted violations.)\n\n* Benefits over default values in receiving function:\n\n  1. ``Options`` objects can save defaults for multiple settings.\n  2. De-couples default values from the functions themselves.\n\n\n\nInstallation\n============\n\n.. code:: bash\n\n    pip install decorated_options\n\nDevelopment\n===========\n\nTo run the all tests run::\n\n    tox\n\nNote, to combine the coverage data from all the tox environments run:\n\n.. list-table::\n    :widths: 10 90\n    :stub-columns: 1\n\n    - - Windows\n      - ::\n\n            set PYTEST_ADDOPTS=--cov-append\n            tox\n\n    - - Other\n      - ::\n\n            PYTEST_ADDOPTS=--cov-append tox\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmusically-ut%2Fdecorated_options","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmusically-ut%2Fdecorated_options","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmusically-ut%2Fdecorated_options/lists"}