[FEAT][API] Privacy Metrics Batch Job Creation
- Dominant language
- Go
- Stars
- 6
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## Description
Adds the ability to create a privacy metrics batch job
## Request
### Method
POST
### URL
/jobs/metrics/privacy_batch
### Request Parameters
| Parameter | Description | Required | example |
|---|---|---|---|
| kind | Job kind | True | privacy_metrics_batch |
| parameters | Parameters for the privacy metrics batch job | True | JSON object |
### Request Body
The request body is a JSON object with the following structure:
```json
{
"kind": "privacy_metrics_batch",
"parameters": {
"dataset_uuid": "UUID of the dataset to analyze",
"configs": [
{
"privacy_metric_kind": "KIND_OF_PRIVACY_METRIC",
"model_kind": "KIND_OF_MODEL",
"model_parameters": {
"parameter_name": "parameter_value"
}
}
]
}
}
```
## Result
### Result parameters
| Parameter | Description | Required | example |
|---|---|---|---|
| id | Id of the privacy metrics batch job | True | UUID |
| kind | Job kind | True | privacy_metrics_batch |
| created_at | Date and time when the privacy metrics batch job was created | True | 2023-07-18T13:37:42.938919Z |
| status | Status of the privacy metrics batch job | True | created |
| error_message | Error message if the privacy metrics batch job failed | False | null |
| traceback | Traceback if the privacy metrics batch job failed | False | null |
| result | Result of the privacy metrics batch job | False | JSON object |
| parameters | Parameters of the privacy metrics batch job | True | JSON object |
| current_progress | Current progress of the privacy metrics batch job | False | JSON object |
### Result Body
The result body is a JSON object with the following structure:
```json
{
"kind": "privacy_metrics_batch",
"parameters": {
"dataset_uuid": "UUID of the dataset to analyze",
"configs": [
{
"privacy_metric_kind": "KIND_OF_PRIVACY_METRIC",
"model_kind": "KIND_OF_MODEL",
"model_parameters": {
"parameter_name": "parameter_value"
}
}
]
},
"result": {
"privacy_metrics": [
{
"privacy_metric_kind": "KIND_OF_PRIVACY_METRIC",
"model_kind": "KIND_OF_MODEL",
"model_parameters": {
"parameter_name": "parameter_value"
},
"value": "VALUE_OF_PRIVACY_METRIC"
}
]
}
}
```
## Example Curl Request
### Request
```
curl --location --request POST 'http://localhost:8080/jobs/metrics/privacy_batch' \
--header 'Content-Type: application/json' \
--data-raw '{
"kind": "privacy_metrics_batch",
"parameters": {
"dataset_uuid": "f20de20c-0677-460a-a60e-725fb441bf58",
"configs": [
{
"privacy_metric_kind": "K_ANONYMITY",
"model_kind": "LINEAR_REGRESSION",
"model_parameters": {
"alpha": 0.001,
"max_iter": 1000
}
}
]
}
}'
```
### Curl Response
```
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "581de059-1552-45d7-a612-5e5db722f0e6",
"kind": "privacy_metrics_batch",
"created_at": "2023-07-18T13:37:42.938919Z",
"status": "created",
"error_message": null,
"traceback": null,
"result": null,
"parameters": {
"dataset_uuid": "f20de20c-0677-460a-a60e-725fb441bf58",
"configs": [
{
"privacy_metric_kind": "K_ANONYMITY",
"model_kind": "LINEAR_REGRESSION",
"model_parameters": {
"alpha": 0.001,
"max_iter": 1000
}
}
]
},
"current_progress": null
}
```
## Go server
### Struct
```go
type PrivacyMetricsBatchJob struct {
ID UUID
Kind JobKind
CreatedAt time.Time
Status JobStatus
ErrorMessage *string
Traceback *string
Result *PrivacyMetricsBatchResult
Parameters PrivacyMetricsBatchParameters
CurrentProgress *JobProgress
}
```
### Handler
```go
func (s *Server) createPrivacyMetricsBatchJob(ctx context.Context, w http.ResponseWriter, r *http.Request) {
var req PrivacyMetricsBatchJobCreate
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
if req.Kind != JobKindPrivacyMetricsBatch {
http.Error(w, "Invalid job kind", http.StatusBadRequest)
return
}
job, err := s.Service.CreatePrivacyMetricsBatchJob(ctx, req.Parameters)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(job); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
```
## Links
- [Jobs.create_privacy_metrics_batch_job](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L617)
- [PrivacyMetricsBatchJobCreate](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L617)
- [PrivacyMetricsBatchJob](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L617)
## Automated Issue Details
Dear visitor,
This issue has been automatically generated from the Octopize project [avatar-python](https://github.com/octopize/avatar-python/) to make SIGO compatible. Please vote with a thumbs up or thumbs down to assess the quality of the automatic generation.
Best regards,
The SIGO Team
Contributor guide
Research direction
Start with the linked avatar-python API reference and the shown createPrivacyMetricsBatchJob handler. Compare it with existing Go job creation paths, then trace PrivacyMetricsBatchJobCreate, PrivacyMetricsBatchJob, and Service.CreatePrivacyMetricsBatchJob. Done means POST /jobs/metrics/privacy_batch accepts the documented request and returns the documented job response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100