code: def _guildfile_resource(spec, depdef):
      m = GUILDFILE_RES_P.match(spec)
      if m is None:
          return None
      model_name = m.group(1)
      modeldef = depdef.opdef.guildfile.models.get(model_name)
      if modeldef is None:
          raise OpDependencyError(
              f"model '{model_name}' in resource '{spec}' required by operation "
              f"'{depdef.opdef.fullname}' is not defined"
          )
      res_name = m.group(2)
      return _modeldef_resource(modeldef, res_name, depdef.opdef)
  
imports: import os
  import re
  import logging
  import typing
  from guild import cli
  from guild import resolver
  from guild import resourcedef
  from guild import util
label_desc: Use image node_id 12 for calling a global function with example usage: _guildfile_resource(spec, depdef) and returns: _modeldef_resource, None