Total Flex Credits for a Project

Total Flex Credits for a Project#

This example demonstrates how to calculate the total Flex Credits consumed by a project. The script iterates through all cases within a project, retrieves the cost of each case, and provides a total sum.

To use the script, you need to replace the placeholder project_id with the ID of your target project.

 1import flow360 as fl
 2
 3project_id = "prj-842fe363-fb66-4d33-85f2-384a88a448e7"  # Replace with your project ID
 4
 5project = fl.Project.from_cloud(project_id=project_id)
 6case_ids = project.get_case_ids()
 7total_fc_cost = 0
 8for case in case_ids:
 9    case = fl.Case.from_cloud(case_id=case)
10    print(f"{case.name}: cost = {case.info.computeCost}")
11    total_fc_cost += case.info.computeCost
12
13print(f"Total flex credits used for project {project_id}: {total_fc_cost}")