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

Create system for plugin modules to tie into specified hooks #29

Closed
ewels opened this issue Sep 18, 2015 · 2 comments
Closed

Create system for plugin modules to tie into specified hooks #29

ewels opened this issue Sep 18, 2015 · 2 comments
Assignees
Milestone

Comments

@ewels
Copy link
Member

ewels commented Sep 18, 2015

Could create another setuptools entrypoints class (multiqc.hooks.v1?) that could create a list of functions to run at different points in the code.

@ewels
Copy link
Member Author

ewels commented Oct 13, 2015

Refactoring issue to be more specific, now that #61 has covered some of the original scope.

@ewels ewels changed the title Get each module to return a dict, trigger a hook Create system for plugin modules to tie into specified hooks Oct 13, 2015
@ewels
Copy link
Member Author

ewels commented Oct 13, 2015

A load of pseudocode to pen down roughly how I see this working:

Plugin setuptools code:

 entry_points = {
  'multiqc.hooks.v1': 'mypluginhooks = myplugin.hooks'
}

Then in myplugin:

def hooks(trigger):
  return triggers.get(trigger, None)

triggers = {
  'click' : click_trigger,
  'modules_start': modules_start_trigger,
  'modules_end': modules_end_trigger
}

def click_trigger():
  """ Could add some extra click arguments here """
  pass

def modules_start_trigger():
  """ Runs before modules start """
  pass

def modules_end_trigger():
  """ Runs when modules finish """
  pass

Finally, in multiqc:

# Load the hooks
hook_functions = []
for entry_point in pkg_resources.iter_entry_points('multiqc.hooks.v1'):
  hook_functions.append(entry_point.load())

# Function to run the hooks
def multiqc_trigger(trigger):
  for h in hook_functions:
    h(trigger)

# .. do some stuff, trigger the hook ..
multiqc_trigger('modules_end')

@ewels ewels modified the milestone: v0.3 Oct 19, 2015
ewels added a commit that referenced this issue Oct 22, 2015
@ewels ewels mentioned this issue Oct 22, 2015
@ewels ewels closed this as completed in #76 Oct 22, 2015
alexiswl pushed a commit to alexiswl/MultiQC that referenced this issue Aug 15, 2022
* Add scATAC metrics

* missing file

* Update search_patterns.yaml

Co-authored-by: Lee <slee2@illumina.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant