Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • L LHCb
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 193
    • Issues 193
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Jira
    • Jira
  • Merge requests 43
    • Merge requests 43
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • LHCbLHCb
  • LHCb
  • Merge requests
  • !3797

Add Options.apply_binds to allow applications to bind before calling user code

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Chris Burr requested to merge add-lbexec-apply_binds into master Sep 28, 2022
  • Overview 3
  • Commits 1
  • Pipelines 2
  • Changes 2

In DaVinci a few cases have come up where code ends up looking like:

@configurable
def my_thing(process="MyDefault"):
    ...

Users then use this thing by running:

my_thing(process=options.process)

This gets a bit annoying when code starts being nested with there being multiple layers of

def my_func(process="MyDefault"):
    return my_other_func(process=process)

def my_other_func(process="MyDefault"):
    return my_thing(process=process)

A slightly better option is to make process a keyword only argument and bind:

@configurable
def my_thing(*, process):
    ...

def my_func():
    return my_other_func()

def my_other_func():
    return my_thing()

# Usage looks like
with my_thing.bind(process=options.process):
    my_func() 

This MR expands this slightly by allowing the application-specific Options class to automatically apply binds so the user code doesn't need to use bind. See DaVinci!731 (merged) for an example of this being used.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: add-lbexec-apply_binds