async def download(self): """Downloads the uploaded problem as an instance of `Problem`""" if not self.uploaded_uri: raise Exception( "StreamingProblem may not be downloaded before it is uploaded") coords = await self._get_upload_coords() blob = coords["container_client"].get_blob_client(coords["blob_name"]) contents = await download_blob(blob.url) return Problem.deserialize(contents, self.name)
def test_deserialize(self): count = 2 terms = [] for i in range(count): terms.append(Term(c=i, indices=[i, i + 1])) problem = Problem(name="test", terms=terms) deserialized = Problem.deserialize(problem.serialize(), problem.name) self.assertEqual(problem.name, deserialized.name) self.assertEqual(problem.problem_type, deserialized.problem_type) self.assertEqual(count, len(deserialized.terms)) self.assertEqual(problem.init_config, deserialized.init_config) self.assertEqual(Term(c=0, indices=[0, 1]), problem.terms[0]) self.assertEqual(Term(c=1, indices=[1, 2]), problem.terms[1])