コード例 #1
0
class BcbioPBSPROEngineSetLauncher(PBSPROLauncher,
                                   launcher.BatchClusterAppMixin):
    """Launch Engines using PBSPro"""
    batch_file_name = Unicode(u'pbspro_engines',
                              config=True,
                              help="batch file name for the engine(s) job.")
    tag = traitlets.Unicode("", config=True)
    cores = traitlets.Integer(1, config=True)
    mem = traitlets.Unicode("", config=True)
    array_cmd = traitlets.Unicode("", config=True)
    default_template = Unicode(u"""#!/bin/sh
#PBS -V
#PBS -N {tag}-e
{resources}
{array_cmd}
cd $PBS_O_WORKDIR
%s %s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
    """ % (' '.join(map(pipes.quote,
                        engine_cmd_argv)), ' '.join(timeout_params)))

    def start(self, n):
        """Start n engines by profile or profile_dir."""
        resources = "#PBS -l select=1:ncpus=%d" % self.cores
        if self.mem:
            resources += ":mem=%smb" % int(float(self.mem) * 1024)
        self.context["resources"] = resources
        self.context["cores"] = self.cores
        self.context["tag"] = self.tag if self.tag else "bcbio"
        self.context["array_cmd"] = "" if n == 1 else "#PBS -J 1-%i" % n
        return super(BcbioPBSPROEngineSetLauncher, self).start(n)
コード例 #2
0
class BcbioTORQUEControllerLauncher(TORQUELauncher,
                                    launcher.BatchClusterAppMixin):
    """Launch a controller using Torque."""
    batch_file_name = Unicode(unicode("torque_controller" + str(uuid.uuid4())),
                              config=True,
                              help="batch file name for the engine(s) job.")
    cores = traitlets.Integer(1, config=True)
    tag = traitlets.Unicode("", config=True)
    resources = traitlets.Unicode("", config=True)
    default_template = Unicode("""#!/bin/sh
#PBS -V
#PBS -N {tag}-c
#PBS -j oe
#PBS -l nodes=1:ppn={cores}
{resources}
cd $PBS_O_WORKDIR
%s --ip=* --log-to-file --profile-dir="{profile_dir}" --cluster-id="{cluster_id}" %s
""" % (' '.join(map(pipes.quote,
                    controller_cmd_argv)), ' '.join(controller_params)))

    def start(self):
        """Start the controller by profile or profile_dir."""
        try:
            self.context["cores"] = self.cores
            self.context["tag"] = self.tag if self.tag else "bcbio"
            self.context["resources"] = "\n".join(
                _prep_torque_resources(self.resources))
            return super(BcbioTORQUEControllerLauncher, self).start(1)
        except:
            self.log.exception("Controller start failed")
コード例 #3
0
class BcbioPBSEngineSetLauncher(launcher.PBSEngineSetLauncher):
    """Custom launcher handling heterogeneous clusters on PBS.
    """
    batch_file_name = Unicode(unicode("pbs_engines" + str(uuid.uuid4())))
    cores = traitlets.Integer(1, config=True)
    mem = traitlets.Unicode("", config=True)
    tag = traitlets.Unicode("", config=True)
    pename = traitlets.Unicode("", config=True)
    resources = traitlets.Unicode("", config=True)
    default_template = traitlets.Unicode("""#PBS -V
#PBS -j oe
#PBS -S /bin/sh
#PBS -q {queue}
#PBS -N {tag}-e
#PBS -t 1-{n}
{mem}
%s %s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
""" % (' '.join(map(pipes.quote, engine_cmd_argv)),
       ' '.join(timeout_params)))

    def start(self, n):
        self.context["cores"] = self.cores
        self.context["pename"] = str(self.pename)
        if self.mem:
            self.context["mem"] = "#PBS -l mem=%smb" % int(float(self.mem) * 1024)
        else:
            self.context["mem"] = ""
        self.context["tag"] = self.tag if self.tag else "bcbio"
        return super(BcbioPBSEngineSetLauncher, self).start(n)
コード例 #4
0
class BcbioSGEControllerLauncher(launcher.SGEControllerLauncher):
    batch_file_name = Unicode(unicode("sge_controller" + str(uuid.uuid4())))
    tag = traitlets.Unicode("", config=True)
    resources = traitlets.Unicode("", config=True)
    queue_template = Unicode('')
    default_template = traitlets.Unicode(u"""#$ -V
#$ -cwd
#$ -w w
#$ -S /bin/sh
#$ -N {tag}-c
{queue}
{resources}
%s --ip=* --log-to-file --profile-dir="{profile_dir}" --cluster-id="{cluster_id}" %s
""" % (' '.join(map(pipes.quote, controller_cmd_argv)),
       ' '.join(controller_params)))
    def start(self):
        self.context["tag"] = self.tag if self.tag else "bcbio"
        self.context["resources"] = "\n".join([_prep_sge_resource(r)
                                               for r in str(self.resources).split(";")
                                               if r.strip()])
        if self.queue:
            self.context["queue"] = "#$ -q %s" % self.queue
        else:
            self.context["queue"] = ""
        return super(BcbioSGEControllerLauncher, self).start()
コード例 #5
0
class BcbioOLDSLURMEngineSetLauncher(SLURMLauncher,
                                     launcher.BatchClusterAppMixin):
    """Launch engines using SLURM for version < 2.6"""
    machines = traitlets.Integer(1, config=True)
    account = traitlets.Unicode("", config=True)
    timelimit = traitlets.Unicode("", config=True)
    batch_file_name = Unicode(unicode("SLURM_engines" + str(uuid.uuid4())),
                              config=True,
                              help="batch file name for the engine(s) job.")

    default_template = Unicode(u"""#!/bin/sh
#SBATCH -A {account}
#SBATCH --job-name ipengine
#SBATCH -N {machines}
#SBATCH -t {timelimit}
srun -N {machines} -n {n} %s %s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
    """ % (' '.join(map(pipes.quote,
                        engine_cmd_argv)), ' '.join(timeout_params)))

    def start(self, n):
        """Start n engines by profile or profile_dir."""
        self.context["machines"] = self.machines
        self.context["account"] = self.account
        self.context["timelimit"] = self.timelimit
        return super(BcbioOLDSLURMEngineSetLauncher, self).start(n)
コード例 #6
0
class D3Sankey(widgets.DOMWidget):
    # the name of the requirejs module (no .js!)
    _view_module = traitlets.Unicode(
        'nbextensions/ipythond3sankey/js/widget_d3sankey',
        sync=True)

    # the name of the Backbone.View subclass to be used
    _view_name = traitlets.Unicode(
        'D3SankeyView',
        sync=True
    )

    # the name of the CSS file to load with this widget
    _view_style = traitlets.Unicode(
        'nbextensions/ipythond3sankey/css/widget_d3sankey',
        sync=True
    )

    # the actual value: lists of nodes and links
    nodes = traitlets.List(sync=True)
    links = traitlets.List(sync=True)

    # margins & size
    margin_top = traitlets.Float(1, sync=True)
    margin_right = traitlets.Float(1, sync=True)
    margin_bottom = traitlets.Float(6, sync=True)
    margin_left = traitlets.Float(1, sync=True)
    width = traitlets.Float(960, sync=True)
    height = traitlets.Float(500, sync=True)

    unit = traitlets.Unicode('', sync=True)
コード例 #7
0
class Tangle(TangleBase):
    """
    The base Tangle class: subclass this if you know your way around
    `traitlets`.

    Otherwise, check out `tangle`.
    """
    _view_name = traitlets.Unicode("TangleView", sync=True)
    _view_module = traitlets.Unicode(
        "/nbextensions/ipytangle/js/tangle_view.js", sync=True)

    # compatibilty with core types (interact)
    description = traitlets.Unicode("Tangle", sync=True)
    value = traitlets.Instance(sync=True, klass=TangleBase)

    # for the future?
    _tangle_prefix = traitlets.Unicode("", sync=True)
    _tangle_upstream_traits = traitlets.Tuple(sync=True)
    _tangle_cell_hiding = traitlets.Bool(sync=True)

    def __init__(self, *args, **kwargs):
        _dummy = widgets.DOMWidget()
        kwargs["_tangle_upstream_traits"] = tuple(_dummy.trait_names())
        super(Tangle, self).__init__(*args, **kwargs)
        self.value = self
        self.on_trait_change(self._notify_value)

    def _notify_value(self, name, old, new):
        if name != "value":
            self._notify_trait("value", self, self)
コード例 #8
0
class BcbioTORQUEEngineSetLauncher(TORQUELauncher, launcher.BatchClusterAppMixin):
    """Launch Engines using Torque"""
    cores = traitlets.Integer(1, config=True)
    mem = traitlets.Unicode("", config=True)
    tag = traitlets.Unicode("", config=True)
    resources = traitlets.Unicode("", config=True)
    batch_file_name = Unicode(unicode("torque_engines" + str(uuid.uuid4())),
                              config=True, help="batch file name for the engine(s) job.")
    default_template = Unicode(u"""#!/bin/sh
#PBS -V
#PBS -j oe
#PBS -N {tag}-e
#PBS -t 1-{n}
#PBS -l nodes=1:ppn={cores}
{mem}
{resources}
cd $PBS_O_WORKDIR
%s %s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
    """ % (' '.join(map(pipes.quote, engine_cmd_argv)),
           ' '.join(timeout_params)))

    def start(self, n):
        """Start n engines by profile or profile_dir."""
        try:
            self.context["cores"] = self.cores
            if self.mem:
                self.context["mem"] = "#PBS -l mem=%smb" % int(float(self.mem) * 1024)
            else:
                self.context["mem"] = ""
            self.context["tag"] = self.tag if self.tag else "bcbio"
            self.context["resources"] = "\n".join(_prep_torque_resources(self.resources))
            return super(BcbioTORQUEEngineSetLauncher, self).start(n)
        except:
            self.log.exception("Engine start failed")
コード例 #9
0
ファイル: report.py プロジェクト: caizikun/labcore
class Result(documents.Document):

    title = traitlets.Unicode()
    smalltitle = traitlets.Unicode()

    value = traitlets.Any()
    date = traitlets.Instance(datetime.datetime)

    def __init__(self, *args, **kwargs):
        super(Result, self).__init__(*args, **kwargs)
        if self.date is None:
            self.date = datetime.datetime.now()

    def _result_html(self):
        if hasattr(self.value, '__html__'):
            return self.value.__html__()
        if hasattr(self.value, '__repr_html__'):
            return self.value.__repr_html__()
        elif isinstance(self.value, sympy.Expr):
            return sympy.latex(self.value)
        else:
            return str(self.value)

    def __repr_html__(self):
        template = env.get_template('base_report.html')
        return template.render(report = self)
コード例 #10
0
class BcbioLSFEngineSetLauncher(launcher.LSFEngineSetLauncher):
    """Custom launcher handling heterogeneous clusters on LSF.
    """
    batch_file_name = Unicode(unicode("lsf_engine" + str(uuid.uuid4())))
    cores = traitlets.Integer(1, config=True)
    mem = traitlets.Unicode("", config=True)
    tag = traitlets.Unicode("", config=True)
    resources = traitlets.Unicode("", config=True)
    job_array_template = Unicode('')
    queue_template = Unicode('')
    default_template = traitlets.Unicode("""#!/bin/sh
#BSUB -q {queue}
#BSUB -J {tag}-e[1-{n}]
#BSUB -oo bcbio-ipengine.bsub.%%J
#BSUB -n {cores}
#BSUB -R "span[hosts=1]"
{mem}
{resources}
%s %s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
    """ % (' '.join(map(pipes.quote, engine_cmd_argv)),
           ' '.join(timeout_params)))

    def start(self, n):
        self.context["cores"] = self.cores
        if self.mem:
            # scale memory to kb
            mem = int(float(self.mem) * 1024.0 * 1024.0)
            self.context["mem"] = "#BSUB -M %s" % mem
        else:
            self.context["mem"] = ""
        self.context["tag"] = self.tag if self.tag else "bcbio"
        self.context["resources"] = _format_lsf_resources(self.resources)
        return super(BcbioLSFEngineSetLauncher, self).start(n)
コード例 #11
0
    class IPythonProgressWidget(widgets.DOMWidget):
        """IPython widget for displaying a progress bar."""

        # pylint: disable=too-many-public-methods
        _view_name = traitlets.Unicode('NengoProgressBar', sync=True)
        progress = traitlets.Float(0., sync=True)
        text = traitlets.Unicode(u'', sync=True)

        FRONTEND = '''
        require(["widgets/js/widget", "widgets/js/manager"],
            function(widget, manager) {
          if (typeof widget.DOMWidgetView == 'undefined') {
            widget = IPython;
          }
          if (typeof manager.WidgetManager == 'undefined') {
            manager = IPython;
          }

          var NengoProgressBar = widget.DOMWidgetView.extend({
            render: function() {
              // $el is the DOM of the widget
              this.$el.css({width: '100%', marginBottom: '0.5em'});
              this.$el.html([
                '<div style="',
                    'width: 100%;',
                    'border: 1px solid #cfcfcf;',
                    'border-radius: 4px;',
                    'text-align: center;',
                    'position: relative;">',
                  '<div class="pb-text" style="',
                      'position: absolute;',
                      'width: 100%;">',
                    '0%',
                  '</div>',
                  '<div class="pb-bar" style="',
                      'background-color: #bdd2e6;',
                      'width: 0%;',
                      'transition: width 0.1s linear;">',
                    '&nbsp;',
                  '</div>',
                '</div>'].join(''));
            },

            update: function() {
              this.$el.css({width: '100%', marginBottom: '0.5em'});
              var progress = 100 * this.model.get('progress');
              var text = this.model.get('text');
              this.$el.find('div.pb-bar').width(progress.toString() + '%');
              this.$el.find('div.pb-text').text(text);
            },
          });

          manager.WidgetManager.register_widget_view(
            'NengoProgressBar', NengoProgressBar);
        });'''

        @classmethod
        def load_frontend(cls):
            """Loads the JavaScript front-end code required by then widget."""
            get_ipython().run_cell_magic('javascript', '', cls.FRONTEND)
コード例 #12
0
class HeatmapWidget(W.DOMWidget):
    _view_name = T.Unicode('HeatmapView', sync=True)
    heatmap_data = T.List(sync=True)
    row_labels = T.List(sync=True)
    col_labels = T.List(sync=True)
    hcrow = T.List(sync=True)
    hccol = T.List(sync=True)
    minval = T.Float(sync=True)
    maxval = T.Float(sync=True)
    html_style = T.Unicode(sync=True)
コード例 #13
0
class BcbioPBSControllerLauncher(launcher.PBSControllerLauncher):
    batch_file_name = Unicode(unicode("pbs_controller" + str(uuid.uuid4())))
    tag = traitlets.Unicode("", config=True)
    default_template = traitlets.Unicode(u"""#PBS -V
#PBS -S /bin/sh
#PBS -N {tag}-c
%s --ip=* --log-to-file --profile-dir="{profile_dir}" --cluster-id="{cluster_id}" %s
""" % (' '.join(map(pipes.quote, controller_cmd_argv)),
       ' '.join(controller_params)))

    def start(self):
        self.context["tag"] = self.tag if self.tag else "bcbio"
        return super(BcbioPBSControllerLauncher, self).start()
コード例 #14
0
class VariationDataProperties(JsonTraits):
    info_text = "Variation data properties"

    num_snps = Numeric(0, desc="Number of SNPs")
    num_individuals = Integer(0, desc="Number of individuals")
    snp_effect_annotation = tls.Unicode(
        "", desc="Flag for SNP annotation: yes or no")
    individual_names = tls.List(tls.Unicode)
コード例 #15
0
class BcbioLSFControllerLauncher(launcher.LSFControllerLauncher):
    batch_file_name = Unicode(unicode("lsf_controller" + str(uuid.uuid4())))
    tag = traitlets.Unicode("", config=True)
    resources = traitlets.Unicode("", config=True)
    job_array_template = Unicode('')
    queue_template = Unicode('')
    default_template = traitlets.Unicode("""#!/bin/sh
#BSUB -q {queue}
#BSUB -J {tag}-c
#BSUB -oo bcbio-ipcontroller.bsub.%%J
{resources}
%s --ip=* --log-to-file --profile-dir="{profile_dir}" --cluster-id="{cluster_id}" %s
    """ % (' '.join(map(pipes.quote, controller_cmd_argv)),
           ' '.join(controller_params)))
    def start(self):
        self.context["tag"] = self.tag if self.tag else "bcbio"
        self.context["resources"] = _format_lsf_resources(self.resources)
        return super(BcbioLSFControllerLauncher, self).start()
コード例 #16
0
class BcbioLSFControllerLauncher(launcher.LSFControllerLauncher):
    default_template = traitlets.Unicode("""#!/bin/sh
#BSUB -J bcbio-ipcontroller
#BSUB -oo bcbio-ipcontroller.bsub.%%J
%s --ip=* --log-to-file --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
    """ % (' '.join(map(pipes.quote, launcher.ipcontroller_cmd_argv))))

    def start(self):
        return super(BcbioLSFControllerLauncher, self).start()
コード例 #17
0
class BcbioSGEControllerLauncher(launcher.SGEControllerLauncher):
    default_template = traitlets.Unicode(u"""#$ -V
#$ -S /bin/sh
#$ -N ipcontroller
%s --ip=* --log-to-file --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
""" % (' '.join(map(pipes.quote, launcher.ipcontroller_cmd_argv))))

    def start(self):
        return super(BcbioSGEControllerLauncher, self).start()
コード例 #18
0
class BcbioOLDSLURMControllerLauncher(SLURMLauncher, launcher.BatchClusterAppMixin):
    """Launch a controller using SLURM for versions < 2.6"""
    account = traitlets.Unicode("", config=True)
    timelimit = traitlets.Unicode("", config=True)
    batch_file_name = Unicode(unicode("SLURM_controller" + str(uuid.uuid4())),
                              config=True, help="batch file name for the engine(s) job.")

    default_template = Unicode("""#!/bin/sh
#SBATCH -A {account}
#SBATCH --job-name ipcontroller
#SBATCH -t {timelimit}
%s --ip=* --log-to-file --profile-dir="{profile_dir}" --cluster-id="{cluster_id}" %s
""" % (' '.join(map(pipes.quote, controller_cmd_argv)),
       ' '.join(controller_params)))

    def start(self):
        """Start the controller by profile or profile_dir."""
        self.context["account"] = self.account
        self.context["timelimit"] = self.timelimit
        return super(BcbioOLDSLURMControllerLauncher, self).start(1)
コード例 #19
0
class BcbioSLURMControllerLauncher(SLURMLauncher, launcher.BatchClusterAppMixin):
    batch_file_name = Unicode(unicode("SLURM_controller" + str(uuid.uuid4())))
    account = traitlets.Unicode("", config=True)
    timelimit = traitlets.Unicode("", config=True)
    mem = traitlets.Unicode("", config=True)
    tag = traitlets.Unicode("", config=True)
    resources = traitlets.Unicode("", config=True)
    default_template = traitlets.Unicode("""#!/bin/sh
#SBATCH -J {tag}-c
#SBATCH -o bcbio-ipcontroller.out.%%j
#SBATCH -e bcbio-ipcontroller.err.%%j
#SBATCH -A {account}
#SBATCH -t {timelimit}
{mem}
{resources}
%s --ip=* --log-to-file --profile-dir="{profile_dir}" --cluster-id="{cluster_id}" %s
""" % (' '.join(map(pipes.quote, controller_cmd_argv)),
       ' '.join(controller_params)))
    def start(self):
        self.context["account"] = self.account
        self.context["timelimit"] = self.timelimit
        self.context["mem"] = "#SBATCH --mem=%d" % (8 * DEFAULT_MEM_PER_CPU)
        self.context["tag"] = self.tag if self.tag else "bcbio"
        self.context["resources"] = "\n".join(["#SBATCH --%s" % r.strip()
                                               for r in str(self.resources).split(";")
                                               if r.strip()])
        return super(BcbioSLURMControllerLauncher, self).start(1)
コード例 #20
0
class BcbioLSFEngineSetLauncher(launcher.LSFEngineSetLauncher):
    """Custom launcher handling heterogeneous clusters on LSF.
    """
    batch_file_name = Unicode(unicode("lsf_engine" + str(uuid.uuid4())))
    cores = traitlets.Integer(1, config=True)
    numengines = traitlets.Integer(1, config=True)
    mem = traitlets.Unicode("", config=True)
    tag = traitlets.Unicode("", config=True)
    resources = traitlets.Unicode("", config=True)
    job_array_template = Unicode('')
    queue_template = Unicode('')
    default_template = traitlets.Unicode("""#!/bin/sh
#BSUB -q {queue}
#BSUB -J {tag}-e[1-{n}]
#BSUB -oo bcbio-ipengine.bsub.%%J
#BSUB -n {cores}
#BSUB -R "span[hosts=1]"
{mem}
{resources}
{cmd}
""")

    def start(self, n):
        self.context["cores"] = self.cores * self.numengines
        if self.mem:
            # lsf.conf can specify nonstandard units for memory reservation
            lsf_unit = lsf.get_lsf_units(resource=True)
            mem = utils.convert_mb(float(self.mem) * 1024, lsf_unit)
            # check if memory reservation is per core or per job
            if lsf.per_core_reservation():
                mem = mem / self.cores
            mem = mem * self.numengines
            self.context["mem"] = '#BSUB -R "rusage[mem=%s]"' % mem
        else:
            self.context["mem"] = ""
        self.context["tag"] = self.tag if self.tag else "bcbio"
        self.context["resources"] = _format_lsf_resources(self.resources)
        self.context["cmd"] = get_engine_commands(self.context,
                                                  self.numengines)
        return super(BcbioLSFEngineSetLauncher, self).start(n)
コード例 #21
0
class Icon(InstallerMixin, widgets.DOMWidget):
    """
    A widget which can show one or more icons
    """
    icons = traitlets.List(sync=True)
    size = traitlets.Enum(Size, sync=True)
    context = traitlets.Enum(bs.Context, sync=True)

    _view_name = traitlets.Unicode('ipbs/IconView', sync=True)

    def __init__(self, *args, **kwargs):
        kwargs["icons"] = list(args) + kwargs.pop("icons", [])
        super(Icon, self).__init__(**kwargs)
コード例 #22
0
class VariationDataset(JsonTraits):
    info_text = "Variation dataset"

    name = tls.Unicode("no name", desc="Name")
    description = tls.Unicode("none", desc="Description")
    file_format = tls.Unicode("vcf", desc="File format")
    comments = tls.Unicode("", desc="Comments")
    kbase_genome_id = tls.Unicode("", desc="Genome identifier")
    kbase_genome_name = tls.Unicode("", desc="Genome name")
    shock_node_id = tls.Unicode("", desc="Shock node ID")
    properties = tls.Instance(VariationDataProperties, ())
    command_used = tls.Unicode("unspecified", desc="Command")

    def __repr__(self):
        return json.dumps(self.as_json())
コード例 #23
0
class BcbioSGEEngineSetLauncher(launcher.SGEEngineSetLauncher):
    """Custom launcher handling heterogeneous clusters on SGE.
    """
    batch_file_name = Unicode(unicode("sge_engine" + str(uuid.uuid4())))
    cores = traitlets.Integer(1, config=True)
    pename = traitlets.Unicode("", config=True)
    resources = traitlets.Unicode("", config=True)
    mem = traitlets.Unicode("", config=True)
    tag = traitlets.Unicode("", config=True)
    default_template = traitlets.Unicode("""#$ -V
#$ -cwd
#$ -b y
#$ -j y
#$ -S /bin/sh
#$ -q {queue}
#$ -N {tag}-e
#$ -t 1-{n}
#$ -pe {pename} {cores}
{mem}
{resources}
echo \($SGE_TASK_ID - 1\) \* 0.5 | bc | xargs sleep
%s %s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
""" % (' '.join(map(pipes.quote, engine_cmd_argv)),
       ' '.join(timeout_params)))

    def start(self, n):
        self.context["cores"] = self.cores
        if self.mem:
            self.context["mem"] = "#$ -l mem_free=%sM" % int(float(self.mem) * 1024)
        else:
            self.context["mem"] = ""
        self.context["tag"] = self.tag if self.tag else "bcbio"
        self.context["pename"] = str(self.pename)
        self.context["resources"] = "\n".join(["#$ -l %s" % r.strip()
                                               for r in str(self.resources).split(";")
                                               if r.strip()])
        return super(BcbioSGEEngineSetLauncher, self).start(n)
コード例 #24
0
class FileUpload(Question):

    encoding = traits.Unicode("b")

    def check(self, responses, student_id=None):
        if responses[0]:
            filename = os.path.join(
                FILE_UPLOAD_DIR,
                self.__class__.__name__ + "_" + str(student_id))
            fout = open(filename, 'w' + self.encoding)
            fout.write(responses[0])
            fout.close()
            responses[0] = "File uploaded successfully!"
        else:
            responses[0] = ""
        return {"scores": [""], "comments": [responses[0]]}
コード例 #25
0
ファイル: report.py プロジェクト: caizikun/labcore
class Report(documents.Document):
    title = traitlets.Unicode()
    results = traitlets.List(documents.Reference(Result))
    date = traitlets.Instance(datetime.datetime)

    def __init__(self, *args, **kwargs):
        super(Report, self).__init__(*args, **kwargs)
        if self.date is None:
            self.date = datetime.datetime.now()

    def __html__(self):
        template = env.get_template('report_base.html')
        return template.render(report = self)

    def make_report(self, report_folder,openbrowser = True):
        save_html_report(self.__html__(), report_folder,
                         openbrowser=openbrowser)
コード例 #26
0
class BcbioLSFEngineSetLauncher(launcher.LSFEngineSetLauncher):
    """Custom launcher handling heterogeneous clusters on LSF.
    """
    cores = traitlets.Integer(1, config=True)
    default_template = traitlets.Unicode("""#!/bin/sh
#BSUB -q {queue}
#BSUB -J bcbio-ipengine[1-{n}]
#BSUB -oo bcbio-ipengine.bsub.%%J
#BSUB -n {cores}
#BSUB -R "span[hosts=1]"
%s %s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
    """ % (' '.join(map(
        pipes.quote, launcher.ipengine_cmd_argv)), ' '.join(timeout_params)))

    def start(self, n):
        self.context["cores"] = self.cores
        return super(BcbioLSFEngineSetLauncher, self).start(n)
コード例 #27
0
class BcbioPBSPROEngineSetLauncher(PBSPROLauncher, launcher.BatchClusterAppMixin):
    """Launch Engines using PBSPro"""
    batch_file_name = Unicode(u'pbspro_engines', config=True,
                              help="batch file name for the engine(s) job.")
    tag = traitlets.Unicode("", config=True)
    default_template = Unicode(u"""#!/bin/sh
#PBS -V
#PBS -N {tag}-e
cd $PBS_O_WORKDIR
%s %s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
    """ % (' '.join(map(pipes.quote, engine_cmd_argv)),
           ' '.join(timeout_params)))

    def start(self, n):
        """Start n engines by profile or profile_dir."""
        self.context["tag"] = self.tag if self.tag else "bcbio"
        return super(BcbioPBSPROEngineSetLauncher, self).start(n)
コード例 #28
0
class BcbioPBSPROControllerLauncher(PBSPROLauncher, launcher.BatchClusterAppMixin):
    """Launch a controller using PBSPro."""

    batch_file_name = Unicode(u'pbspro_controller', config=True,
                              help="batch file name for the controller job.")
    tag = traitlets.Unicode("", config=True)
    default_template = Unicode("""#!/bin/sh
#PBS -V
#PBS -N {tag}-c
cd $PBS_O_WORKDIR
%s --ip=* --log-to-file --profile-dir="{profile_dir}" --cluster-id="{cluster_id}" %s
""" % (' '.join(map(pipes.quote, controller_cmd_argv)),
       ' '.join(controller_params)))

    def start(self):
        """Start the controller by profile or profile_dir."""
        self.context["tag"] = self.tag if self.tag else "bcbio"
        return super(BcbioPBSPROControllerLauncher, self).start(1)
コード例 #29
0
class MultiPartQuestion(Question):
    """
    Question with multiple parts (which are themselves questions)
    """

    active_parts = traits.List()
    list_type = traits.Unicode("a")

    def _parts_changed(self):
        self.active_parts = []
        self.max_pts = []
        for part in self.parts:
            part.seed = self.seed
            self.active_parts.append(part)
            self.max_pts.extend(part.max_pts)

    def to_JSON(self, solution=False):
        data = {
            "type": self.type,
            "text": self.text,
            "parts": [p.to_JSON(solution) for p in self.active_parts],
            "list_type": self.list_type
        }
        if solution: data['solution'] = {}
        return data

    def check(self, responses, student_id=None):
        scores = []
        comments = []
        end = 0
        for i, part in enumerate(self.active_parts):
            # extract responses corresponding to current part
            start = end
            end = start + part.num_answers
            resp = responses[start:end]
            # call the check method for that part
            out = part.check(resp)
            scores.extend(out['scores'])
            comments.extend(out['comments'])
            # write any changes to the answer back
            responses[start:end] = resp
        return {"scores": scores, "comments": comments}
コード例 #30
0
class BcbioSGEEngineSetLauncher(launcher.SGEEngineSetLauncher):
    """Custom launcher handling heterogeneous clusters on SGE.
    """
    cores = traitlets.Integer(1, config=True)
    default_template = traitlets.Unicode("""#$ -V
#$ -cwd
#$ -b y
#$ -j y
#$ -S /bin/sh
#$ -q {queue}
#$ -N bcbio-ipengine
#$ -t 1-{n}
#$ -pe threaded {cores}
%s %s --profile-dir="{profile_dir}" --cluster-id="{cluster_id}"
""" % (' '.join(map(pipes.quote,
                    launcher.ipengine_cmd_argv)), ' '.join(timeout_params)))

    def start(self, n):
        self.context["cores"] = self.cores
        return super(BcbioSGEEngineSetLauncher, self).start(n)