projects sub-package#
Project class
- class Project(name: str, *, append: bool = False)#
Bases:
object
Projects management class.
The Project class allows tasks to be collected under the umbrella of a single container object. All tasks submitted in the context of an opened project will be associated with that project and can be retrieved altogether using the project as a filter. A project can be created and managed declaratively or using a context manager.
Example usage:
project = inductiva.projects.Project("test_project") project.start() simulator.run(...) # Submitted to `'test_project'` project.stop()
This is equivalent to:
with inductiva.projects.Project("test_project"): simulator.run(...)
- __init__(name: str, *, append: bool = False)#
Initialize the Project instance.
- Parameters:
name (str) – The name of the project.
append (bool) – A flag indicating that new tasks can be appended to the project. If set to False (default), task submission will fail, even though the project might be opened.
- close()#
Close the project.
Calls to the get_current_project will return None after the project is closed. Consecutive calls to this method are idempotent.
- describe() str #
Generates a string description of the object
- Returns:
- A string description of the object. Includes project name,
total number of tasks and the number of tasks by status.
- Return type:
str
- download_outputs()#
Downloads all the outputs for all the tasks in the project.
All the files will be stored inside inductiva_output/<project_name>/<task_id’s>.
- get_info() ProjectInfo #
Get project information.
Get updated information on the project. This method executes a call to the backend to retrieve the most recent information about this project and stores it internally so that it becomes available through the Project.info property. This method is suitable when up-to-date information is required.
- get_tasks(last_n: int = -1, force_update=False, status: str | TaskStatusCode | None = None) List[Tasks] #
Get the the tasks of this project.
Get the tasks that belong to this project, eventually filtered by status. By default, it will return all the tasks, irrespectively of their status. This method will only do a request to the back end if the list of tasks is None (never requested the list of tasks) or if force_update is passed as True.
- Parameters:
last_n (int) – The number of tasks with repect to the submission time to fectch. If last_n<=0 we fetch all tasks submitted to the project.
force_update (bool) – Forces the request to the back end, even if we already have a list of tasks associated with this project.
status – Status of the tasks to get. If None, tasks with any status will be returned.
- property info: ProjectInfo#
Returns project info.
It makes no requests to the backend. Instead it uses previously stored information. Therefore it can be outdated. For a method that requests the most recent data from the backend use: get_info.
- list(last_n: int = -1, force_update=False, status: str | TaskStatusCode | None = None) List[Tasks] #
Get the the tasks of this project.
Get the tasks that belong to this project, eventually filtered by status. By default, it will return all the tasks, irrespectively of their status. This method will only do a request to the back end if the list of tasks is None (never requested the list of tasks) or if force_update is passed as True.
- Parameters:
last_n (int) – The number of tasks with repect to the submission time to fectch. If last_n<=0 we fetch all tasks submitted to the project.
force_update (bool) – Forces the request to the back end, even if we already have a list of tasks associated with this project.
status – Status of the tasks to get. If None, tasks with any status will be returned.
- property name: str#
- open()#
Open the project.
Open the project and make it the active one in the calling thread. An opened project will ensure that calls to the get_current_project function will return this project. Consecutive calls to this method are idempotent.
- Raises:
RuntimeError if another opened project exists, i.e., –
get_current_project –
- property opened: bool#
Checks if the project is open.
- wait()#
Wait for all the tasks in a project to complete.
- get_current_project()#
Get the current active project.
Returns the currently active project in the calling thread. If no project has been defined, the default project (None) will be returned.
- get_projects()#
Gets all the user’s projects.