Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions saagieapi/jobs/gql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,3 @@
moveJob(jobId: $jobId, targetPlatformId: $targetPlatformId, targetProjectId: $targetProjectId)
}
"""

GQL_GENERATE_JOB_DESCRIPTION = """
mutation editJobWithAiGeneratedDescriptionMutation($jobId: UUID!) {
editJobWithAiGeneratedDescription(jobId: $jobId) {
id
description
aiDescriptionVersionNumber
}
}
"""
36 changes: 0 additions & 36 deletions saagieapi/jobs/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1970,39 +1970,3 @@ def move_job(self, job_id: str, target_platform_id: int, target_project_id: str)
"targetProjectId": target_project_id,
},
)

def generate_description_by_ai(self, job_id: str):
"""Generate a description for a job using AI.
Be careful, by calling this function the code contained in the job package will be sent to OpenAI
and thus will not be secured anymore by Saagie DataOps Platform.
Otherwise, the function returns an error if the description is already the one generated by AI.

Parameters
----------
job_id : str
UUID of your job (see README on how to find it)

Returns
-------
dict
Dict of the generated description

Examples
--------
>>> saagie_api.jobs.generate_description_by_ai(job_id=job_id)
{
'editJobWithAiGeneratedDescription': {
'id': 'bfa25e4a-1796-4ebb-8c3d-138f74146973',
'description': 'The purpose of this code is to display the message "Hello World" on the screen.',
'aiDescriptionVersionNumber': 1
}
}
"""
# if executed a second time and the description is already the one generated by AI,
# it will return an error and I don't know how to handle it
# example : TransportQueryError: {'message': 'Job not valid', 'path': ['editJobWithAiGeneratedDescription'],
# 'extensions': {'job.description': 'Job description is already generated', 'classification':'ValidationError'}}

return self.saagie_api.client.execute(
query=gql(GQL_GENERATE_JOB_DESCRIPTION), variable_values={"jobId": job_id}
)
10 changes: 0 additions & 10 deletions tests/integration/jobs_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,6 @@ def test_move_job(create_then_delete_job, create_global_project):

assert job_init["job"]["name"] == job_after["job"]["name"]

@staticmethod
def test_generate_description_by_ai(create_then_delete_job, create_global_project):
conf = create_global_project
job_id = create_then_delete_job

result = conf.saagie_api.jobs.generate_description_by_ai(job_id=job_id)

assert "editJobWithAiGeneratedDescription" in result
assert result["editJobWithAiGeneratedDescription"]["id"] == job_id

@staticmethod
def test_get_info_by_alias(create_global_project, create_then_delete_job):
conf = create_global_project
Expand Down
17 changes: 0 additions & 17 deletions tests/unit/jobs_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1391,20 +1391,3 @@ def test_move_job(self, saagie_api_mock):
instance.move_job(**job_params)

saagie_api_mock.client.execute.assert_called_with(query=expected_query, variable_values=params)

def test_generate_description_by_ai_gql(self):
self.client.validate(gql(GQL_GENERATE_JOB_DESCRIPTION))

def test_generate_description_by_ai(self, saagie_api_mock):
instance = Jobs(saagie_api_mock)

job_id = "860b8dc8-e634-4c98-b2e7-f9ec32ab4771"
params = {
"jobId": job_id,
}

expected_query = gql(GQL_GENERATE_JOB_DESCRIPTION)

instance.generate_description_by_ai(job_id=job_id)

saagie_api_mock.client.execute.assert_called_with(query=expected_query, variable_values=params)
10 changes: 0 additions & 10 deletions tests/unit/resources/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,6 @@ type Mutation {
# You can only edit a job if you have at least the editor role in the project associated to the job or in all projects.
editJob(job: JobEditionInput!): Job!

# Edit a job description by AI.
#
# The job description will be edited and replaced by a text generated by a generative AI based on the job's source code,
# which will be sent to a service external to Saagie.
#
# You can only edit a job if you have at least the editor role in the project associated to the job or in all projects.
editJobWithAiGeneratedDescription(jobId: UUID!): Job!

# Add a job version.
#
# **Fields validation:**
Expand Down Expand Up @@ -1196,8 +1188,6 @@ type Job {
# Only alphanumeric and underscore characters are allowed.
alias: String
description: String
aiDescriptionVersionNumber: Int
aiDescriptionState: JobAiGeneratedDescriptionState
countJobInstance: Int
# Attribute checkInPipelineInstance is now deprecated
instances(limit: Int, skip: Int, checkInPipelineInstance: Boolean, lastExecution: Boolean): [JobInstance!]
Expand Down
Loading