diff --git a/pori_python/ipr/connection.py b/pori_python/ipr/connection.py index d85ebf7..254a1cf 100644 --- a/pori_python/ipr/connection.py +++ b/pori_python/ipr/connection.py @@ -101,6 +101,17 @@ def upload_report( # if async is used, the response for reports-async contains either 'jobStatus' # or 'report'. jobStatus is no longer available once the report is successfully # uploaded. + + projects = self.get("project") + project_names = [item['name'] for item in projects] + + # if project is not exist, create one + if content['project'] not in project_names: + try: + self.post("project", {'name': content['project']}) + except Exception as err: + raise Exception(f"create project failure: {err}") + initial_result = self.post("reports-async", content) report_id = initial_result["ident"]