def submit(self, filename):
        print(
            lh.blue(CrowdAIEvents.Misc["FILE_UPLOAD"] +
                    " : Preparing for file upload"))
        # Validate that the file is indeed a valid gzip file
        if not tarfile.is_tarfile(filename):
            err_message = "`{}` doesnot seem to be a valid tar file. The grader accepts only valid tar dumps of docker containers.".format(
                filename)
            raise Exception(err_message)

        response = self._obtain_presigned_url()

        print(lh.blue(CrowdAIEvents.Misc["FILE_UPLOAD"] + " : Uploading file"))
        url = response["presigned_url"]
        file_key = response["s3_key"]

        #Instantiate Progress Trackers
        self.instantiate_progress_bars(1)
        r = requests.put(url,
                         data=IterableToFileAdapter(
                             upload_in_chunks(filename, self, chunksize=5000)))
        self.close_all_progress_bars()

        result = self.execute_function("grade_submission",
                                       [{
                                           "file_key": file_key
                                       }])[0]
        del result["job_state"]
        return result
    def submit(self, filename):
        #TODO: Add validation
        #TODO: Add LOADS of client side validation
        print(
            lh.blue(CrowdAIEvents.Misc["FILE_UPLOAD"] +
                    " : Preparing for file upload"))

        self.verbose(False)
        response = self._obtain_presigned_url()
        self.verbose(True)

        print(lh.blue(CrowdAIEvents.Misc["FILE_UPLOAD"] + " : Uploading file"))
        url = response["presigned_url"]
        file_key = response["file_key"]

        #Instantiate Progress Trackers
        self.instantiate_progress_bars(1)
        r = requests.put(url,
                         data=IterableToFileAdapter(
                             upload_in_chunks(filename, self, chunksize=5000)))
        self.close_all_progress_bars()

        result = self.execute_function("grade_submission",
                                       [{
                                           "file_key": file_key
                                       }])[0]
        return result
Пример #3
0
    def submit(self, filename):
        print(
            lh.blue(
                CrowdAIEvents.Misc["FILE_UPLOAD"] +
                " : Preparing for file upload"))
        # Validate that the file is indeed a valid gzip file
        response = self._obtain_presigned_url()

        print(lh.blue(CrowdAIEvents.Misc["FILE_UPLOAD"]+" : Uploading file"))
        url = response["presigned_url"]
        file_key = response["s3_key"]

        # Instantiate Progress Trackers
        self.instantiate_progress_bars(1)
        requests.put(
            url,
            data=IterableToFileAdapter(
                upload_in_chunks(filename, self, chunksize=5000)
                )
            )
        self.close_all_progress_bars()

        result = self.execute_function(
                "grade_submission",
                [{"file_key": file_key}]
                )[0]
        del result["job_state"]
        return result
Пример #4
0
    def submit(self, filename, small_test=False):
        #TODO: Add validation
        #TODO: Add LOADS of client side validation
        print(
            lh.blue(CrowdAIEvents.Misc["FILE_UPLOAD"] +
                    " : Preparing for file upload"))

        # Validate that the file is indeed a valid gzip file
        try:
            _fp = gzip.open(filename, 'rb')
            _d = _fp.read()
        except IOError:
            err_message = "`{}` doesnot seem to be a valid gzip file. The grader acccepts only gzipped version of the prediction file.".format(
                filename)
            raise InvalidFileError(err_message)

        self.verbose(False)
        response = self._obtain_presigned_url()
        self.verbose(True)

        print(lh.blue(CrowdAIEvents.Misc["FILE_UPLOAD"] + " : Uploading file"))
        url = response["presigned_url"]
        file_key = response["s3_key"]

        #Instantiate Progress Trackers
        self.instantiate_progress_bars(1)
        r = requests.put(url,
                         data=IterableToFileAdapter(
                             upload_in_chunks(filename, self, chunksize=5000)))
        self.close_all_progress_bars()

        result = self.execute_function("grade_submission",
                                       [{
                                           "file_key": file_key,
                                           "small_test": small_test
                                       }])[0]

        del result["job_state"]
        return result