Projects#
- class saagieapi.projects.Projects(saagie_api)#
Bases:
object
- create(name: str, group: str = None, role: str = None, groups_and_roles: List[Dict] | None = None, description: str = '', jobs_technologies_allowed: Dict = None, apps_technologies_allowed: Dict = None) Dict #
Create a new project on the platform with all the job technologies and the app technologies of the official Saagie catalog if no technologies are specified.
- Parameters:
name (str) – Name of the project (must not already exist)
groups_and_roles (list[dict], optional) – dict of groups and their respective roles on the project
description (str, optional) – Description of the project
jobs_technologies_allowed (list, optional) – Dict of catalog and jobs technologies allowed for the project
apps_technologies_allowed (list, optional) – Dict of catalog and apps technologies allowed for the project
- Returns:
Dict of created project
- Return type:
- Raises:
ValueError – If given unknown role value
Examples
>>> saagie_client.projects.create( ... name="Project_A", ... groups_and_roles=[{"my_group": "Manager"}], ... jobs_technologies_allowed={"saagie": ["python", "spark"]}, ... apps_technologies_allowed={"saagie": ["Jupyter Notebook"]} ... ) { 'createProject': { 'id': '09515109-e8d3-4ed0-9ab7-5370efcb6cb5', 'name': 'Project_A', 'creator': 'toto.tata' } }
- delete(project_id: str) Dict #
Delete a given project NB: You can only delete projects where you have the manager role
- Parameters:
project_id (str) – UUID of your project (see README on how to find it)
- Returns:
dict of archived project
- Return type:
Examples
>>> saagieapi.projects.delete(project_id="8321e13c-892a-4481-8552-5be4d6cc5df4") { "deleteProject": True }
- edit(project_id: str, name: str = None, group: str = None, role: str = None, groups_and_roles: List[Dict] | None = None, description: str = None, jobs_technologies_allowed: Dict = None, apps_technologies_allowed: Dict = None) Dict #
Edit a project
- Parameters:
project_id (str) – UUID of your project (see README on how to find it)
name (str, optional) – Name of the project If not filled, defaults to current value, else it will change the job’s name
group (None or str, optional) – Authorization management: name of the group to add the given role to, cannot be set if groups_and_roles is already set
role (str, optional) – Authorization management: role to give to the given group on the project cannot be set if groups_and_roles is already set
groups_and_roles (list[dict], optional) – dict of groups and their respective roles on the project, cannot be set if group or role are already set
description (str, optional) – Description of the project If not filled, defaults to current value, else it will change the job’s description
jobs_technologies_allowed (list, optional) – Dict of catalog and jobs technologies allowed for the project If not filled, defaults to current value, else it will change the jobs technologies allowed
apps_technologies_allowed (list, optional) – Dict of catalog and apps technologies allowed for the project If not filled, defaults to current value, else it will change the apps technologies allowed
- Returns:
Dict of created project
- Return type:
- Raises:
ValueError – If given unknown role value
Examples
>>> saagie_client.projects.edit( ... project_id="9a261ae0-fd73-400c-b9b6-b4b63ac113eb", ... name="PROJECT B", ... groups_and_roles=[{"my_group": "Viewer"}], ... description="new desc", ... jobs_technologies_allowed={"saagie": ["r"]}, ... apps_technologies_allowed={"saagie": ["Dash"]} ... ) { 'editProject': { 'id': '9a261ae0-fd73-400c-b9b6-b4b63ac113eb', 'name': 'PROJECT B', 'creator': 'toto.tata' } }
- export(project_id: str, output_folder: str, error_folder: str | None = '', versions_limit: int | None = None, versions_only_current: bool = False, project_only_env_vars: bool = False) bool #
Export the project in a folder
- Parameters:
project_id (str) – Project ID
output_folder (str) – Path to store the exported project
error_folder (str, optional) – Path to store the non exported job/app/pipeline ID in case of error. If not set, error is not write
versions_limit (int, optional) – Maximum limit of versions to fetch per job/app/pipeline. Fetch from most recent to the oldest
versions_only_current (bool, optional) – Whether to only fetch the current version of each job/app/pipeline
project_only_env_vars (bool, optional) – True if only project environment variable should be exported False otherwise
- Returns:
True if project is successfully exported False otherwise
- Return type:
Examples
>>> saagieapi.projects.export( ... project_id="8321e13c-892a-4481-8552-5be4d6cc5df4", ... output_folder="./output/", ... error_folder= "./error/", ... versions_only_current = True, ... project_only_env_vars = True ... ) True
- get_apps_technologies(project_id: str, pprint_result: bool | None = None) Dict #
List available apps technology ids for the project
- Parameters:
- Returns:
Dict of available apps technology ids
- Return type:
Examples
>>> saagieapi.projects.get_apps_technologies(project_id="8321e13c-892a-4481-8552-5be4d6cc5df4") { 'appTechnologies': [ { 'id': '11d63963-0a74-4821-b17b-8fcec4882863' }, { 'id': '56ad4996-7285-49a6-aece-b9525c57c619' }, { 'id': 'd0b55623-9dc0-4e03-89c7-6a2494387a4f' } ] }
- get_id(project_name: str) Dict #
Get the project id with the project name
Examples
>>> saagieapi.projects.get_id("Project A") "8321e13c-892a-4481-8552-5be4d6cc5df4"
- get_info(project_id: str, pprint_result: bool | None = None) Dict #
Get information for a given project (id, name, creator, description, jobCount and status) NB: You can only get project information if you have at least the viewer role on this project or on all projects.
- Parameters:
- Returns:
Dict of project information
- Return type:
Examples
>>> saagieapi.projects.get_info(project_id="8321e13c-892a-4481-8552-5be4d6cc5df4") { "project": { "name":"Project A", "creator":"john.doe", "description":"My project A", "jobsCount":49, "status":"READY" } }
- get_info_by_name(project_name: str, pprint_result: bool | None = None) Dict #
Get information for a given project (id, name, creator, description, jobCount and status) NB: You can only get project information if you have at least the viewer role on this project or on all projects.
- Parameters:
- Returns:
Dict of project information
- Return type:
Examples
>>> saagieapi.projects.get_info_by_name(project_name="Project A") { "projectByName": { "id": "8321e13c-892a-4481-8552-5be4d6cc5df4", "name":"Project A", "creator":"john.doe", "description":"My project A", "jobsCount":49, "status":"READY" } }
- get_jobs_technologies(project_id: str, pprint_result: bool | None = None) Dict #
List available jobs technologies id for the project
- Parameters:
- Returns:
Dict of available jobs technology ids
- Return type:
Examples
>>> saagieapi.projects.get_jobs_technologies(project_id="8321e13c-892a-4481-8552-5be4d6cc5df4") { 'technologiesByCategory': [ { 'jobCategory': 'Extraction', 'technologies': [ { 'id': '9bb75cad-69a5-4a9d-b059-811c6cde589e', '__typename': 'Technology' }, { 'id': 'f267085d-cc52-4ae8-ad9e-af8721c81127', '__typename': 'Technology' } ] }, { 'jobCategory': 'Processing', 'technologies': [ { 'id': '9bb75cad-69a5-4a9d-b059-811c6cde589e', '__typename': 'Technology' } ] }, { 'jobCategory': 'Smart App', 'technologies': [] } ] }
- get_rights(project_id: str) Dict #
List rights associated for the project
- Parameters:
project_id (str) – UUID of your project (see README on how to find it)
- Returns:
Dict of rights associated for the project
- Return type:
Examples
>>> saagieapi.projects.get_rights(project_id="8321e13c-892a-4481-8552-5be4d6cc5df4") { 'rights': [ { 'name': 'manager_group', 'role': 'ROLE_PROJECT_MANAGER', 'isAllProjects': True }, { 'name': 'my_group', 'role': 'ROLE_PROJECT_MANAGER', 'isAllProjects': False } ] }
- import_from_json(path_to_folder: str = None) bool #
Import a project from a folder
- Parameters:
path_to_folder (str, optional) – Path to the folder of the project to import
- Returns:
True if project is imported False otherwise
- Return type:
Examples
>>> saagieapi.projects.import_from_json(path_to_folder="./output/") True
- list(pprint_result: bool | None = None) Dict #
Get information for all projects (id, name, creator, description, jobCount and status) NB: You can only list projects you have rights on.
- Parameters:
pprint_result (bool, optional) – Whether to pretty print the result of the query, default to saagie_api.pprint_global
- Returns:
Dict of projects information
- Return type:
Examples
>>> saagieapi.projects.list() { "projects":[ { "id":"8321e13c-892a-4481-8552-5be4d6cc5df4", "name":"Project A", "creator":"john.doe", "description":"My project A", "jobsCount":49, "status":"READY" }, { "id":"33b70e1b-3111-4376-a839-12d2f93c323b", "name":"Project B", "creator":"john.doe", "description":"My project B", "jobsCount":1, "status":"READY" } ] }