예제 #1
0
파일: shell.py 프로젝트: findcomrade/isbio
def build_report(report_data, request_data, report_property, sections):
    """ Assembles report home folder, configures DRMAA and R related files
		and spawns a new process for reports DRMAA job on cluster.

	:param report_data: report info dictionary
	:type report_data: dict
	:param request_data: a copy of request object
	:type request_data: HTTPrequest
	:param report_property: report property form
	:type report_property: breezeForms.ReportPropsForm
	:param sections: a list of 'Rscripts' db objects
	:type sections: list
	:return: True
	:rtype: bool
	"""

    from breeze.models import Project, UserProfile, ReportType, Report
    from django.contrib.auth.models import User

    log = logger.getChild("build_report")
    assert isinstance(log, logging.getLoggerClass())
    assert isinstance(request_data.user, User)

    # get the request ReportType
    rt = ReportType.objects.get(type=report_data["report_type"])
    # list of users that will have access to this report
    shared_users = aux.extract_users(request_data.POST.get("Groups"), request_data.POST.get("Individuals"))
    if shared_users == list() and request_data.POST.get("shared"):
        shared_users = request_data.POST.getlist("shared")
        # author
    the_user = request_data.user
    the_user.prof = UserProfile.objects.get(user=the_user)
    assert isinstance(the_user.prof, UserProfile)

    # create initial instance so that we can use its db id
    dbitem = Report(
        _type=rt,
        _name=report_data["instance_name"],
        _author=the_user,
        project=Project.objects.get(id=request_data.POST.get("project")),
        _institute=the_user.prof.institute_info,
        _breeze_stat=JobStat.INIT,
        rora_id=report_data["instance_id"],
    )
    dbitem.assemble(request_data=request_data, shared_users=shared_users, sections=sections)
    dbitem.submit_to_cluster()

    return True
예제 #2
0
def build_report(report_data, request_data, report_property, sections):
    """ Assembles report home folder, configures DRMAA and R related files
		and spawns a new process for reports DRMAA job on cluster.

	:param report_data: report info dictionary
	:type report_data: dict
	:param request_data: a copy of request object
	:type request_data: HTTPrequest
	:param report_property: report property form
	:type report_property: breezeForms.ReportPropsForm
	:param sections: a list of 'Rscripts' db objects
	:type sections: list
	:return: True
	:rtype: bool
	"""

    from breeze.models import Project, UserProfile, ReportType, Report, ComputeTarget
    from django.contrib.auth.models import User
    log = logger.getChild('build_report')
    assert isinstance(log, logging.getLoggerClass())
    assert isinstance(request_data.user, User)

    # get the request ReportType
    rt = ReportType.objects.get(type=report_data['report_type'])
    # list of users that will have access to this report
    shared_users = aux.extract_users(request_data.POST.get('Groups'),
                                     request_data.POST.get('Individuals'))
    if shared_users == list() and request_data.POST.get('shared'):
        shared_users = request_data.POST.getlist('shared')
    # author
    the_user = request_data.user
    the_user.prof = UserProfile.objects.get(user=the_user)
    assert isinstance(the_user.prof, UserProfile)

    # target profile :
    target = ComputeTarget.objects.get(pk=request_data.POST.get('target'))
    assert target.id in rt.ready_id_list  # TODO make a validator in the form section

    # create initial instance so that we can use its db id
    dbitem = Report(
        _type=rt,
        _name=report_data['instance_name'],
        _author=the_user,
        project=Project.objects.get(id=request_data.POST.get('project')),
        _institute=the_user.prof.institute_info,
        _breeze_stat=JobStat.INIT,
        target=target,
        rora_id=report_data['instance_id'])
    dbitem.assemble(request_data=request_data,
                    shared_users=shared_users,
                    sections=sections)
    dbitem.submit_to_cluster()

    return True
예제 #3
0
파일: shell.py 프로젝트: Fclem/isbio
def build_report(report_data, request_data, report_property, sections):
    """ Assembles report home folder, configures DRMAA and R related files
		and spawns a new process for reports DRMAA job on cluster.

	:param report_data: report info dictionary
	:type report_data: dict
	:param request_data: a copy of request object
	:type request_data: HTTPrequest
	:param report_property: report property form
	:type report_property: breezeForms.ReportPropsForm
	:param sections: a list of 'Rscripts' db objects
	:type sections: list
	:return: True
	:rtype: bool
	"""

    from breeze.models import Project, UserProfile, ReportType, Report, ComputeTarget
    from django.contrib.auth.models import User

    log = logger.getChild("build_report")
    assert isinstance(log, logging.getLoggerClass())
    assert isinstance(request_data.user, User)

    # get the request ReportType
    rt = ReportType.objects.get(type=report_data["report_type"])
    # list of users that will have access to this report
    shared_users = aux.extract_users(request_data.POST.get("Groups"), request_data.POST.get("Individuals"))
    if shared_users == list() and request_data.POST.get("shared"):
        shared_users = request_data.POST.getlist("shared")
        # author
    the_user = request_data.user
    the_user.prof = UserProfile.objects.get(user=the_user)
    assert isinstance(the_user.prof, UserProfile)

    # target profile :
    from django.core.exceptions import ObjectDoesNotExist

    target_id = request_data.POST.get("target")
    try:
        # target = ComputeTarget.objects.get_ready().filter(pk=target_id)
        target = ComputeTarget.objects.get(pk=target_id)
    except ObjectDoesNotExist:
        from django.contrib import messages

        messages.add_message(request_data, messages.ERROR, "No such target %s" % target_id)
        return False
    if not target.is_ready:
        from django.contrib import messages

        messages.add_message(request_data, messages.ERROR, "target %s is either disable or not ready" % target)
        return False
        # target = ComputeTarget.objects.get(pk=request_data.POST.get('target'))
        # if target.id not in rt.ready_id_list: # TODO make a validator in the form section
        # if target not in ComputeTarget.objects.ready():
        # 	from django.contrib import messages
        # 	messages.add_message(request_data, messages.INFO, 'target %s is either disable or not ready' % target)
        # 	return False

        # create initial instance so that we can use its db id
    dbitem = Report(
        _type=rt,
        _name=report_data["instance_name"],
        _author=the_user,
        project=Project.objects.get(id=request_data.POST.get("project")),
        _institute=the_user.prof.institute_info,
        _breeze_stat=JobStat.INIT,
        target=target,
        rora_id=report_data["instance_id"],
    )
    dbitem.assemble(request_data=request_data, shared_users=shared_users, sections=sections)
    dbitem.submit_to_cluster()

    return True