class_docstr: Object representing a single bash job to execute.
  
  Examples
  --------
  
  Create a batch object:
  
  >>> b = Batch()
  
  Create a new bash job that prints hello to a temporary file `t.ofile`:
  
  >>> j = b.new_job()
  >>> j.command(f'echo "hello" > {j.ofile}')
  
  Write the temporary file `t.ofile` to a permanent location
  
  >>> b.write_output(j.ofile, 'hello.txt')
  
  Execute the DAG:
  
  >>> b.run()
  
  Notes
  -----
  This class should never be created directly by the user. Use :meth:`.Batch.new_job`
  or :meth:`.Batch.new_bash_job` instead.
class_docstr_tok: ["Object","representing","a","single","bash","job","to","execute",".","Examples","--","--","--","--","Create","a","batch","object",":",">",">",">","b","=","Batch","(",")","Create","a","new","bash","job","that","prints","hello","to","a","temporary","file","`","t.ofile","`",":",">",">",">","j","=","b.new_job","(",")",">",">",">","j.command","(","f'echo","``","hello","''",">","{","j.ofile","}","'",")","Write","the","temporary","file","`","t.ofile","`","to","a","permanent","location",">",">",">","b.write_output","(","j.ofile",",","'hello.txt","'",")","Execute","the","DAG",":",">",">",">","b.run","(",")","Notes","--","--","-","This","class","should","never","be","created","directly","by","the","user",".","Use",":","meth",":","`",".Batch.new_job","`","or",":","meth",":","`",".Batch.new_bash_job","`","instead","."]
docstr: Declare a resource group for a job.
  
  Examples
  --------
  
  Declare a resource group:
  
  >>> b = Batch()
  >>> input = b.read_input_group(bed='data/example.bed',
  ...                            bim='data/example.bim',
  ...                            fam='data/example.fam')
  >>> j = b.new_job()
  >>> j.declare_resource_group(tmp1={'bed': '{root}.bed',
  ...                                'bim': '{root}.bim',
  ...                                'fam': '{root}.fam',
  ...                                'log': '{root}.log'})
  >>> j.command(f'plink --bfile {input} --make-bed --out {j.tmp1}')
  >>> b.run()  # doctest: +SKIP
  
  Warning
  -------
  Be careful when specifying the expressions for each file as this is Python
  code that is executed with `eval`!
  
  Parameters
  ----------
  mappings:
      Keywords (in the above example `tmp1`) are the name(s) of the
      resource group(s).  File names may contain arbitrary Python
      expressions, which will be evaluated by Python `eval`.  To use the
      keyword as the file name, use `{root}` (in the above example {root}
      will be replaced with `tmp1`).
  
  Returns
  -------
  Same job object with resource groups set.
docstr_tok: ["Declare","a","resource","group","for","a","job",".","Examples","--","--","--","--","Declare","a","resource","group",":",">",">",">","b","=","Batch","(",")",">",">",">","input","=","b.read_input_group","(","bed='data\/example.bed","'",",","...","bim='data\/example.bim","'",",","...","fam='data\/example.fam","'",")",">",">",">","j","=","b.new_job","(",")",">",">",">","j.declare_resource_group","(","tmp1=","{","'bed","'",":","'","{","root","}",".bed","'",",","...","'bim","'",":","'","{","root","}",".bim","'",",","...","'fam","'",":","'","{","root","}",".fam","'",",","...","'log","'",":","'","{","root","}",".log","'","}",")",">",">",">","j.command","(","f'plink","--","bfile","{","input","}","--","make-bed","--","out","{","j.tmp1","}","'",")",">",">",">","b.run","(",")","#","doctest",":","+SKIP","Warning","--","--","--","-","Be","careful","when","specifying","the","expressions","for","each","file","as","this","is","Python","code","that","is","executed","with","`","eval","`","!","Parameters","--","--","--","--","--","mappings",":","Keywords","(","in","the","above","example","`","tmp1","`",")","are","the","name","(","s",")","of","the","resource","group","(","s",")",".","File","names","may","contain","arbitrary","Python","expressions",",","which","will","be","evaluated","by","Python","`","eval","`",".","To","use","the","keyword","as","the","file","name",",","use","`","{","root","}","`","(","in","the","above","example","{","root","}","will","be","replaced","with","`","tmp1","`",")",".","Returns","--","--","--","-","Same","job","object","with","resource","groups","set","."]
code: def declare_resource_group(
      self, **mappings: Dict[str, Any]
  ) -> "BashJob":
      """Declare a resource group for a job.
  
      Examples
      --------
  
      Declare a resource group:
  
      >>> b = Batch()
      >>> input = b.read_input_group(bed='data/example.bed',
      ...                            bim='data/example.bim',
      ...                            fam='data/example.fam')
      >>> j = b.new_job()
      >>> j.declare_resource_group(tmp1={'bed': '{root}.bed',
      ...                                'bim': '{root}.bim',
      ...                                'fam': '{root}.fam',
      ...                                'log': '{root}.log'})
      >>> j.command(f'plink --bfile {input} --make-bed --out {j.tmp1}')
      >>> b.run()  # doctest: +SKIP
  
      Warning
      -------
      Be careful when specifying the expressions for each file as this is Python
      code that is executed with `eval`!
  
      Parameters
      ----------
      mappings:
          Keywords (in the above example `tmp1`) are the name(s) of the
          resource group(s).  File names may contain arbitrary Python
          expressions, which will be evaluated by Python `eval`.  To use the
          keyword as the file name, use `{root}` (in the above example {root}
          will be replaced with `tmp1`).
  
      Returns
      -------
      Same job object with resource groups set.
      """
  
      for name, d in mappings.items():
          assert name not in self._resources
          if not isinstance(d, dict):
              raise BatchException(
                  f"value for name '{name}' is not a dict. Found '{type(d)}' instead."
              )
          rg = self._batch._new_resource_group(self, d, root=name)
          self._resources[name] = rg
          _add_resource_to_set(self._valid, rg)
      return self
  
imports: import asyncio
  import inspect
  import os
  import re
  import textwrap
  import warnings
  from shlex import quote
  from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union, cast, Literal
  from typing_extensions import Self
  import hailtop.batch_client.client
  from .None import backend, batch
  from .None import resource
  from .exceptions import BatchException
label_desc: Use image node_id 2 for calling the BashJob obj's underlying member method code with example usage: obj.declare_resource_group() and returns: self