Example #1
0
def update_setup_py_with_new_version(package_version_id):
    package_version = PackageVersion.objects.get(pk=package_version_id)
    internal_package = InternalPackage.objects.get(
        pk=package_version.package.pk)
    gh_helper = GitHubHelper(internal_package.owner,
                             internal_package.git_repo.name)
    setup_py = gh_helper.view_file('setup.py')
    setup_py = update_setup_py_new_version(package_version.version_nr,
                                           setup_py)
    gh_helper.update_file('setup.py',
                          contents=setup_py,
                          commit_message="Updated setup.py for new version")
Example #2
0
def task_write_data_schema(experiment_id):
    """Task to write data schema to GitHub in schema/schema.json file
    By converting the schema to dictionary and then to Json"""
    experiment = Experiment.objects.get(pk=experiment_id)
    data_schema = experiment.schema
    data_schema_str = str(json.dumps(data_schema.to_dict()))
    logger.info('writing data schema for %s with schema: %s', experiment,
                data_schema_str)
    github_helper = GitHubHelper(experiment.owner.user,
                                 experiment.git_repo.name)
    github_helper.update_file('schema/schema.json',
                              'Updated data schema by MOOC workbench',
                              data_schema_str)
    username = experiment.owner.user.username
    send_message(username, MessageStatus.SUCCESS,
                 'Data schema successfully updated in GitHub')
    logger.info('writing data schema success for: %s', experiment,
                data_schema_str)