Inside the testFiles folder, there are two zip files, we will use the motorBike.zip file for this tutorial.
Open the config.json file that is inside the folder /src/config.
And add your credentials into the file:
Open a terminal and navigate to the src folder inside the project, and finally execute the
following command to run the example project:
The simulation created by the example project is also visible in the KaleidoSim Cloud user
interface.
The example project will use the credentials stored in the config.json file to log in into the
KaleidoSim API. The code will then execute the following steps using the API:
- Create a project.
- Upload an input file.
- Create a simulation case.
- Run the case.
- Wait for the simulation to complete.
- After the simulation is complete, it downloads the results into a local folder.
You can find the main sequence of these events in the completeCase.py file. By following
the function calls leading from this file, you can see how the API is utilized. As an example of
this please look at the create_project function inside the src/api_requests/projects/ folder,
you can see that we are making a POST request to the API in order to create a new project,
the API will return in response the projectId of the newly created project.
One interesting thing to note is how we are checking to see if the simulation case has
completed. You can see that we are periodically polling the API in the completeCase.py file,
we make a request to get the current status of the simulation. Once the case completes we
move onto the file downloading phase in the src/download_case_files.py file.
Relevant about the example #
The folder api_requests contains functions that can run specific tasks like run a case,
download files, login, create projects, etc. You only need to import them into your function if
you want to create your own code.
The Python example project contains a Readme.md file with relevant information.
Note that every project you create through the API must have a unique name and every
case inside a project must also have a unique name.