How to use the planemo.training.tutorial.Tutorial function in planemo

To help you get started, we’ve selected a few planemo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github galaxyproject / planemo / tests / test_training_tutorial.py View on Github external
def test_tutorial_init_from_existing_tutorial():
    """Test :func:`planemo.training.tutorial.tutorial.init_from_existing_tutorial`."""
    tuto = Tutorial(
        training=training,
        topic=topic)
    # non existing tutorial
    exp_exception = "The tutorial existing_tutorial does not exists. It should be created"
    with assert_raises_regexp(Exception, exp_exception):
        tuto.init_from_existing_tutorial('existing_tutorial')
    # existing tutorial
    create_existing_tutorial('existing_tutorial', tuto_fp, tuto.topic)
    tuto.init_from_existing_tutorial('existing_tutorial')
    assert tuto.title == 'A tutorial to test'
    assert "A learning objective" in tuto.objectives
    assert tuto.time_estimation == "1H"
    assert 'the_best_contributor' in tuto.contributors
    assert '# First section' in tuto.body
    shutil.rmtree("topics")
github galaxyproject / planemo / tests / test_training_tutorial.py View on Github external
def test_tutorial_get_files_from_zenodo():
    """Test :func:`planemo.training.tutorial.tutorial.get_files_from_zenodo`."""
    tuto = Tutorial(
        training=training,
        topic=topic,
        zenodo_link=zenodo_link)
    tuto.datatype_fp = datatype_fp
    files, z_record = tuto.get_files_from_zenodo()
    assert z_record == "1321885"
    # test links
    file_link_prefix = "https://zenodo.org/api/files/51a1b5db-ff05-4cda-83d4-3b46682f921f"
    assert file_link_prefix in tuto.zenodo_file_links[0]
    # test files dict
    assert file_link_prefix in files[0]['url']
    assert files[0]['src'] == 'url'
    assert files[0]['info'] == zenodo_link
    assert "# Please add" in files[0]['ext']
    assert files[1]['ext'] == 'csv'
github galaxyproject / planemo / tests / test_training_tutorial.py View on Github external
def test_tutorial_set_dir_name():
    """Test :func:`planemo.training.tutorial.tutorial.set_dir_name`."""
    tuto = Tutorial(
        training=training,
        topic=topic)
    tuto.name = "the_tuto"
    tuto.set_dir_name()
    assert tuto.name in tuto.dir
    assert tuto.name in tuto.tuto_fp
    assert tuto.name in tuto.slide_fp
    assert tuto.name in tuto.data_lib_fp
    assert tuto.name in tuto.wf_dir
    assert tuto.name in tuto.wf_fp
github galaxyproject / planemo / tests / test_training_tutorial.py View on Github external
def test_tutorial_init_data_lib():
    """Test :func:`planemo.training.tutorial.tutorial.init_data_lib`."""
    tuto = Tutorial(
        training=training,
        topic=topic)
    tuto.init_data_lib()
    assert tuto.data_lib['destination']['type'] == 'library'
    assert tuto.data_lib['items'][0]['name'] == topic.title
    assert tuto.data_lib['items'][0]['items'][0]['name'] == tuto.title
    # from existing data library file
    os.makedirs(tuto.dir)
    tuto.data_lib = {}
    tuto.init_data_lib()
    assert tuto.data_lib['items'][0]['name'] == topic.title
    assert tuto.data_lib['items'][0]['items'][0]['name'] == tuto.title
    # other tutorial already there and add the new one
    tuto.data_lib['items'][0]['items'][0]['name'] = 'Different tutorial'
    save_to_yaml(tuto.data_lib, tuto.data_lib_fp)
    tuto.init_data_lib()
github galaxyproject / planemo / tests / test_training_tutorial.py View on Github external
def test_tutorial_export_workflow_file():
    """Test :func:`planemo.training.tutorial.tutorial.export_workflow_file`."""
    tuto = Tutorial(
        training=training,
        topic=topic)
    os.makedirs(tuto.wf_dir)
    # with worflow fp
    tuto.init_wf_fp = WF_FP
    tuto.export_workflow_file()
    assert os.path.exists(tuto.wf_fp)
    # with workflow id
    tuto.init_wf_fp = None
    os.remove(tuto.wf_fp)
    assert is_galaxy_engine(**KWDS)
    galaxy_url = 'http://%s:%s' % (KWDS['host'], KWDS['port'])
    with engine_context(CTX, **KWDS) as galaxy_engine:
        with galaxy_engine.ensure_runnables_served([RUNNABLE]) as config:
            tuto.init_wf_id = config.workflow_id(WF_FP)
            tuto.training.galaxy_url = galaxy_url
github galaxyproject / planemo / tests / test_training_tutorial.py View on Github external
def test_tutorial_create_hands_on_tutorial():
    """Test :func:`planemo.training.tutorial.tutorial.create_hands_on_tutorial`."""
    tuto = Tutorial(
        training=training,
        topic=topic)
    os.makedirs(tuto.wf_dir)
    # with init_wf_id and no Galaxy URL
    tuto.init_wf_id = 'ID'
    tuto.training.galaxy_url = None
    exp_exception = "No Galaxy URL given"
    with assert_raises_regexp(Exception, exp_exception):
        tuto.create_hands_on_tutorial(CTX)
    # with init_wf_id and no Galaxy API key
    tuto.init_wf_id = 'ID'
    tuto.training.galaxy_url = 'http://%s:%s' % (KWDS['host'], KWDS['port'])
    tuto.training.galaxy_api_key = None
    exp_exception = "No API key to access the given Galaxy instance"
    with assert_raises_regexp(Exception, exp_exception):
        tuto.create_hands_on_tutorial(CTX)
github galaxyproject / planemo / tests / test_training_tutorial.py View on Github external
def test_tutorial_create_tutorial():
    """Test :func:`planemo.training.tutorial.tutorial.create_tutorial`."""
    tuto = Tutorial(
        training=training,
        topic=topic)
    tuto.init_from_kwds({
        'tutorial_name': "my_tuto",
        'tutorial_title': "Title of tuto",
        'hands_on': True,
        'slides': True,
        'workflow': WF_FP,
        'workflow_id': None,
        'zenodo_link': zenodo_link,
        'datatypes': datatype_fp
    })
    tuto.create_tutorial(CTX)
    assert os.path.exists(tuto.dir)
    assert os.path.exists(tuto.tour_dir)
    assert os.path.exists(tuto.wf_dir)
github galaxyproject / planemo / tests / test_training_tutorial.py View on Github external
def test_tutorial_init_from_kwds():
    """Test :func:`planemo.training.tutorial.tutorial.init_from_kwds`."""
    kwds = {
        'tutorial_name': "my_tuto",
        'tutorial_title': "Title of tuto",
        'hands_on': True,
        'slides': True,
        'workflow': WF_FP,
        'workflow_id': 'id',
        'zenodo_link': None,
        'datatypes': datatype_fp
    }
    tuto = Tutorial(
        training=training,
        topic=topic)
    tuto.init_from_kwds(kwds)
    assert tuto.name == "my_tuto"
    assert tuto.title == "Title of tuto"
    assert tuto.zenodo_link == ''
    assert "Which biological questions are addressed by the tutorial?" in tuto.questions
    assert tuto.hands_on
    assert tuto.slides
    assert tuto.init_wf_id == 'id'
    assert tuto.init_wf_fp == WF_FP
    assert tuto.datatype_fp == datatype_fp
    assert "my_tuto" in tuto.dir
github galaxyproject / planemo / planemo / training / __init__.py View on Github external
def check_topic_init_tuto(self):
        """Check that the topic and tutorial are already there and retrieve them."""
        # check topic
        if not self.topic.exists():
            raise Exception("The topic %s does not exists. It should be created" % self.topic.name)
        self.topic.init_from_metadata()
        # initiate the tutorial
        self.tuto = Tutorial(training=self, topic=self.topic)
        self.tuto.init_from_existing_tutorial(self.kwds['tutorial_name'])
        if 'datatypes' in self.kwds:
            self.tuto.datatype_fp = self.kwds['datatypes']
        if 'workflow' in self.kwds:
            self.tuto.init_wf_fp = self.kwds['workflow']
        if 'workflow_id' in self.kwds:
            self.tuto.init_wf_id = self.kwds['workflow_id']
github galaxyproject / planemo / planemo / training / __init__.py View on Github external
def init_training(self, ctx):
        """Create/update a topic/tutorial."""
        if not self.topic.exists():
            info("The topic %s does not exist. It will be created" % self.topic.name)
            self.topic.init_from_kwds(self.kwds)
            self.topic.create_topic_structure()

        if not self.kwds['tutorial_name']:
            if self.kwds["slides"]:
                raise Exception("A tutorial name is needed to create the skeleton of a tutorial slide deck")
            if self.kwds['workflow'] or self.kwds['workflow_id']:
                raise Exception("A tutorial name is needed to create the skeleton of the tutorial from a workflow")
            if self.kwds['zenodo_link']:
                raise Exception("A tutorial name is needed to add Zenodo information")
        else:
            self.tuto = Tutorial(training=self, topic=self.topic)
            self.tuto.init_from_kwds(self.kwds)
            if not self.tuto.exists():
                info("The tutorial %s in topic %s does not exist. It will be created." % (self.tuto.name, self.topic.name))
                self.tuto.create_tutorial(ctx)