Skip to content

Commit 95ecfe9

Browse files
committed
add jobId to dataset source to simplify get status
1 parent b4313ca commit 95ecfe9

File tree

8 files changed

+55
-53
lines changed

8 files changed

+55
-53
lines changed

dataset/src/integrationTest/kotlin/com/cosmotech/dataset/service/DatasetServiceIntegrationTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ class DatasetServiceIntegrationTest : CsmRedisTestBase() {
350350
datasetApiService.uploadTwingraph(organizationSaved.id!!, datasetSaved.id!!, resource)
351351
// add timout for while loop
352352
val timeout = Instant.now()
353-
while (datasetApiService.getDatasetTwingraphStatus(
354-
organizationSaved.id!!, datasetSaved.id!!, "randomJobId") != Dataset.Status.READY.value) {
353+
while (datasetApiService.getDatasetTwingraphStatus(organizationSaved.id!!, datasetSaved.id!!) !=
354+
Dataset.Status.READY.value) {
355355
if (Instant.now().minusSeconds(10).isAfter(timeout)) {
356356
throw Exception("Timeout while waiting for dataset twingraph to be ready")
357357
}
@@ -983,15 +983,15 @@ class DatasetServiceIntegrationTest : CsmRedisTestBase() {
983983
val exception =
984984
assertThrows<CsmAccessForbiddenException> {
985985
datasetApiService.getDatasetTwingraphStatus(
986-
organizationSaved.id!!, datasetSaved.id!!, "randomJobId")
986+
organizationSaved.id!!, datasetSaved.id!!)
987987
}
988988
assertEquals(
989989
"RBAC ${datasetSaved.id!!} - User does not have permission $PERMISSION_READ",
990990
exception.message)
991991
} else {
992992
assertDoesNotThrow {
993993
datasetApiService.getDatasetTwingraphStatus(
994-
organizationSaved.id!!, datasetSaved.id!!, "randomJobId")
994+
organizationSaved.id!!, datasetSaved.id!!)
995995
}
996996
}
997997
}

dataset/src/main/kotlin/com/cosmotech/dataset/service/DatasetServiceImpl.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class DatasetServiceImpl(
270270

271271
dataset.sourceType.takeIf { it == DatasetSourceType.File }
272272
?: throw CsmResourceNotFoundException("SourceType Dataset must be 'File'")
273-
val uploadStatus = getDatasetTwingraphStatus(organizationId, datasetId, "jobIdRandom")
273+
val uploadStatus = getDatasetTwingraphStatus(organizationId, datasetId)
274274
uploadStatus.takeUnless { it == Dataset.Status.PENDING.value }
275275
?: throw CsmResourceNotFoundException("Dataset in use, cannot update. Retry later")
276276

@@ -304,7 +304,6 @@ class DatasetServiceImpl(
304304
override fun getDatasetTwingraphStatus(
305305
organizationId: String,
306306
datasetId: String,
307-
jobId: String
308307
): String {
309308
// This call verify by itself that we have the read authorization in the dataset
310309
val dataset = findDatasetById(organizationId, datasetId)
@@ -330,7 +329,7 @@ class DatasetServiceImpl(
330329
DatasetSourceType.Twincache,
331330
DatasetSourceType.AzureStorage -> {
332331
val twingraphImportJobInfoRequest =
333-
TwingraphImportJobInfoRequest(this, jobId!!, organizationId)
332+
TwingraphImportJobInfoRequest(this, dataset.source!!.jobId!!, organizationId)
334333
this.eventPublisher.publishEvent(twingraphImportJobInfoRequest)
335334
dataset
336335
.takeIf { it.status == Dataset.Status.PENDING }
@@ -384,6 +383,8 @@ class DatasetServiceImpl(
384383
"",
385384
dataset.queries)
386385
this.eventPublisher.publishEvent(graphImportEvent)
386+
387+
datasetRepository.save(dataset.apply { source!!.jobId = requestJobId })
387388
logger.debug("refreshDataset={}", graphImportEvent.response)
388389
return DatasetTwinGraphInfo(
389390
jobId = requestJobId, datasetId = dataset.id, status = dataset.status?.value)

dataset/src/main/openapi/dataset.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ paths:
678678
type: string
679679
format: binary
680680

681-
/organizations/{organization_id}/datasets/{dataset_id}/job/{job_id}/status:
681+
/organizations/{organization_id}/datasets/{dataset_id}/status:
682682
parameters:
683683
- name: organization_id
684684
in: path
@@ -692,12 +692,6 @@ paths:
692692
required: true
693693
schema:
694694
type: string
695-
- name: job_id
696-
in: path
697-
description: the job identifier
698-
required: true
699-
schema:
700-
type: string
701695
get:
702696
operationId: getDatasetTwingraphStatus
703697
tags:
@@ -1623,6 +1617,9 @@ components:
16231617
path:
16241618
type: string
16251619
description: the source location containing the files to import
1620+
jobId:
1621+
type: string
1622+
description: indicate the last import jobId
16261623
required:
16271624
- location
16281625
TwinGraphBatchResult:

dataset/src/test/kotlin/com/cosmotech/dataset/service/DatasetServiceImplTests.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class DatasetServiceImplTests {
319319
twingraphId = "twingraphId")
320320
every { datasetRepository.findById(DATASET_ID) } returns Optional.of(dataset)
321321
every { csmJedisPool.resource.exists(any<String>()) } returns false
322-
val result = datasetService.getDatasetTwingraphStatus(ORGANIZATION_ID, DATASET_ID, "JOB_ID")
322+
val result = datasetService.getDatasetTwingraphStatus(ORGANIZATION_ID, DATASET_ID)
323323
assertEquals(Dataset.Status.DRAFT.value, result)
324324
}
325325

@@ -333,8 +333,7 @@ class DatasetServiceImplTests {
333333
twingraphId = "twingraphId")
334334
every { datasetRepository.findById(DATASET_ID) } returns Optional.of(dataset)
335335
every { csmJedisPool.resource.exists(any<String>()) } returns true
336-
val result =
337-
datasetService.getDatasetTwingraphStatus(ORGANIZATION_ID, DATASET_ID, "JobIdRandom")
336+
val result = datasetService.getDatasetTwingraphStatus(ORGANIZATION_ID, DATASET_ID)
338337
assertEquals(Dataset.Status.READY.value, result)
339338
}
340339

@@ -345,12 +344,13 @@ class DatasetServiceImplTests {
345344
.copy(
346345
status = Dataset.Status.DRAFT,
347346
sourceType = DatasetSourceType.ADT,
347+
source = SourceInfo(location = "test", jobId = "0"),
348348
twingraphId = "twingraphId")
349349
mockkConstructor(TwingraphImportJobInfoRequest::class)
350350
every { anyConstructed<TwingraphImportJobInfoRequest>().response } returns
351351
Dataset.Status.PENDING.value
352352
every { datasetRepository.findById(DATASET_ID) } returns Optional.of(dataset)
353-
val result = datasetService.getDatasetTwingraphStatus(ORGANIZATION_ID, DATASET_ID, "JOB_ID")
353+
val result = datasetService.getDatasetTwingraphStatus(ORGANIZATION_ID, DATASET_ID)
354354
assertEquals(Dataset.Status.PENDING.value, result)
355355
}
356356

@@ -361,14 +361,15 @@ class DatasetServiceImplTests {
361361
.copy(
362362
status = Dataset.Status.PENDING,
363363
sourceType = DatasetSourceType.ADT,
364+
source = SourceInfo(location = "test", jobId = "0"),
364365
twingraphId = "twingraphId")
365366
mockkConstructor(TwingraphImportJobInfoRequest::class)
366367
every { anyConstructed<TwingraphImportJobInfoRequest>().response } returns
367368
Dataset.Status.READY.value
368369
every { datasetRepository.findById(DATASET_ID) } returns Optional.of(dataset)
369370
every { csmJedisPool.resource.exists(any<String>()) } returns true
370371
every { datasetRepository.save(any()) } returnsArgument 0
371-
val result = datasetService.getDatasetTwingraphStatus(ORGANIZATION_ID, DATASET_ID, "JOB_ID")
372+
val result = datasetService.getDatasetTwingraphStatus(ORGANIZATION_ID, DATASET_ID)
372373
assertEquals(Dataset.Status.READY.value, result)
373374
}
374375

@@ -391,13 +392,13 @@ class DatasetServiceImplTests {
391392
.copy(
392393
status = Dataset.Status.DRAFT,
393394
sourceType = DatasetSourceType.ADT,
394-
source = SourceInfo("http://storage.location"),
395+
source = SourceInfo("http://storage.location", jobId = "0"),
395396
twingraphId = "twingraphId")
396397
every { datasetRepository.findById(DATASET_ID) } returns Optional.of(dataset)
397398
every { csmJedisPool.resource.exists(any<String>()) } returns true
398399
every { datasetRepository.save(any()) } returnsArgument 0
399400
val datasetInfo = datasetService.refreshDataset(ORGANIZATION_ID, DATASET_ID)
400-
verify(exactly = 1) { datasetRepository.save(any()) }
401+
verify(atLeast = 1) { datasetRepository.save(any()) }
401402
assertEquals(dataset.id, datasetInfo.datasetId)
402403
assertEquals(dataset.status!!.value, datasetInfo.status)
403404
}

doc/Apis/DatasetApi.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,32 @@ Method | HTTP request | Description
66
------------- | ------------- | -------------
77
[**addDatasetAccessControl**](DatasetApi.md#addDatasetAccessControl) | **POST** /organizations/{organization_id}/datasets/{dataset_id}/security/access | Add a control access to the Dataset
88
[**addOrReplaceDatasetCompatibilityElements**](DatasetApi.md#addOrReplaceDatasetCompatibilityElements) | **POST** /organizations/{organization_id}/datasets/{dataset_id}/compatibility | Add Dataset Compatibility elements.
9-
[**copyDataset**](DatasetApi.md#copyDataset) | **POST** /organizations/{organization_id}/datasets/copy | Copy a Dataset to another Dataset. Source must have a read capable connector and Target a write capable connector.
9+
[**copyDataset**](DatasetApi.md#copyDataset) | **POST** /organizations/{organization_id}/datasets/copy | Copy a Dataset to another Dataset.
1010
[**createDataset**](DatasetApi.md#createDataset) | **POST** /organizations/{organization_id}/datasets | Create a new Dataset
11-
[**createSubDataset**](DatasetApi.md#createSubDataset) | **POST** /organizations/{organization_id}/datasets/{dataset_id}/subdataset | Run a query on a dataset
11+
[**createSubDataset**](DatasetApi.md#createSubDataset) | **POST** /organizations/{organization_id}/datasets/{dataset_id}/subdataset | Create a sub-dataset from the dataset in parameter
1212
[**createTwingraphEntities**](DatasetApi.md#createTwingraphEntities) | **POST** /organizations/{organization_id}/datasets/{dataset_id}/twingraph/{type} | Create new entities in a graph instance
1313
[**deleteDataset**](DatasetApi.md#deleteDataset) | **DELETE** /organizations/{organization_id}/datasets/{dataset_id} | Delete a dataset
1414
[**deleteTwingraphEntities**](DatasetApi.md#deleteTwingraphEntities) | **DELETE** /organizations/{organization_id}/datasets/{dataset_id}/twingraph/{type} | Delete entities in a graph instance
15-
[**downloadTwingraph**](DatasetApi.md#downloadTwingraph) | **GET** /organizations/{organization_id}/datasets/twingraph/download/{hash} | Download a graph compressed in a zip file
15+
[**downloadTwingraph**](DatasetApi.md#downloadTwingraph) | **GET** /organizations/{organization_id}/datasets/twingraph/download/{hash} | Download a graph as a zip file
1616
[**findAllDatasets**](DatasetApi.md#findAllDatasets) | **GET** /organizations/{organization_id}/datasets | List all Datasets
1717
[**findDatasetById**](DatasetApi.md#findDatasetById) | **GET** /organizations/{organization_id}/datasets/{dataset_id} | Get the details of a Dataset
1818
[**getDatasetAccessControl**](DatasetApi.md#getDatasetAccessControl) | **GET** /organizations/{organization_id}/datasets/{dataset_id}/security/access/{identity_id} | Get a control access for the Dataset
1919
[**getDatasetSecurity**](DatasetApi.md#getDatasetSecurity) | **GET** /organizations/{organization_id}/datasets/{dataset_id}/security | Get the Dataset security information
2020
[**getDatasetSecurityUsers**](DatasetApi.md#getDatasetSecurityUsers) | **GET** /organizations/{organization_id}/datasets/{dataset_id}/security/users | Get the Dataset security users list
21-
[**getDatasetTwingraphStatus**](DatasetApi.md#getDatasetTwingraphStatus) | **GET** /organizations/{organization_id}/datasets/{dataset_id}/job/{job_id}/status | Get the status of twingraph import
21+
[**getDatasetTwingraphStatus**](DatasetApi.md#getDatasetTwingraphStatus) | **GET** /organizations/{organization_id}/datasets/{dataset_id}/status | Get the dataset&#39;s refresh job status
2222
[**getTwingraphEntities**](DatasetApi.md#getTwingraphEntities) | **GET** /organizations/{organization_id}/datasets/{dataset_id}/twingraph/{type} | Get entities in a graph instance
23-
[**refreshDataset**](DatasetApi.md#refreshDataset) | **POST** /organizations/{organization_id}/datasets/{dataset_id}/refresh | Refresh dataset
23+
[**refreshDataset**](DatasetApi.md#refreshDataset) | **POST** /organizations/{organization_id}/datasets/{dataset_id}/refresh | Refresh data on dataset from dataset&#39;s source
2424
[**removeAllDatasetCompatibilityElements**](DatasetApi.md#removeAllDatasetCompatibilityElements) | **DELETE** /organizations/{organization_id}/datasets/{dataset_id}/compatibility | Remove all Dataset Compatibility elements from the Dataset specified
2525
[**removeDatasetAccessControl**](DatasetApi.md#removeDatasetAccessControl) | **DELETE** /organizations/{organization_id}/datasets/{dataset_id}/security/access/{identity_id} | Remove the specified access from the given Dataset
26-
[**searchDatasets**](DatasetApi.md#searchDatasets) | **POST** /organizations/{organization_id}/datasets/search | Search Datasets
26+
[**searchDatasets**](DatasetApi.md#searchDatasets) | **POST** /organizations/{organization_id}/datasets/search | Search Datasets by tags
2727
[**setDatasetDefaultSecurity**](DatasetApi.md#setDatasetDefaultSecurity) | **POST** /organizations/{organization_id}/datasets/{dataset_id}/security/default | Set the Dataset default security
2828
[**twingraphBatchQuery**](DatasetApi.md#twingraphBatchQuery) | **POST** /organizations/{organization_id}/datasets/{dataset_id}/batch-query | Run a query on a graph instance and return the result as a zip file in async mode
2929
[**twingraphBatchUpdate**](DatasetApi.md#twingraphBatchUpdate) | **POST** /organizations/{organization_id}/datasets/{dataset_id}/batch | Async batch update by loading a CSV file on a graph instance
30-
[**twingraphQuery**](DatasetApi.md#twingraphQuery) | **POST** /organizations/{organization_id}/datasets/{dataset_id}/twingraph | Run a query on a graph instance and return the result as a json
30+
[**twingraphQuery**](DatasetApi.md#twingraphQuery) | **POST** /organizations/{organization_id}/datasets/{dataset_id}/twingraph | Return the result of a query made on the graph instance as a json
3131
[**updateDataset**](DatasetApi.md#updateDataset) | **PATCH** /organizations/{organization_id}/datasets/{dataset_id} | Update a dataset
3232
[**updateDatasetAccessControl**](DatasetApi.md#updateDatasetAccessControl) | **PATCH** /organizations/{organization_id}/datasets/{dataset_id}/security/access/{identity_id} | Update the specified access to User for a Dataset
3333
[**updateTwingraphEntities**](DatasetApi.md#updateTwingraphEntities) | **PATCH** /organizations/{organization_id}/datasets/{dataset_id}/twingraph/{type} | Update entities in a graph instance
34-
[**uploadTwingraph**](DatasetApi.md#uploadTwingraph) | **POST** /organizations/{organization_id}/datasets/{dataset_id} | Upload Twingraph with ZIP File
34+
[**uploadTwingraph**](DatasetApi.md#uploadTwingraph) | **POST** /organizations/{organization_id}/datasets/{dataset_id} | Upload data from zip file to dataset&#39;s twingraph
3535

3636

3737
<a name="addDatasetAccessControl"></a>
@@ -92,7 +92,9 @@ Name | Type | Description | Notes
9292
# **copyDataset**
9393
> DatasetCopyParameters copyDataset(organization\_id, DatasetCopyParameters)
9494
95-
Copy a Dataset to another Dataset. Source must have a read capable connector and Target a write capable connector.
95+
Copy a Dataset to another Dataset.
96+
97+
Not implemented!
9698

9799
### Parameters
98100

@@ -144,17 +146,17 @@ Name | Type | Description | Notes
144146
# **createSubDataset**
145147
> Dataset createSubDataset(organization\_id, dataset\_id, SubDatasetGraphQuery)
146148
147-
Run a query on a dataset
149+
Create a sub-dataset from the dataset in parameter
148150

149-
Run a query on a dataset
151+
Create a copy of the dataset using the results of the list of queries given in parameter.
150152

151153
### Parameters
152154

153155
Name | Type | Description | Notes
154156
------------- | ------------- | ------------- | -------------
155157
**organization\_id** | **String**| the Organization identifier | [default to null]
156158
**dataset\_id** | **String**| the Dataset identifier | [default to null]
157-
**SubDatasetGraphQuery** | [**SubDatasetGraphQuery**](../Models/SubDatasetGraphQuery.md)| the query to run |
159+
**SubDatasetGraphQuery** | [**SubDatasetGraphQuery**](../Models/SubDatasetGraphQuery.md)| the Cypher query to filter |
158160

159161
### Return type
160162

@@ -259,9 +261,9 @@ null (empty response body)
259261
# **downloadTwingraph**
260262
> File downloadTwingraph(organization\_id, hash)
261263
262-
Download a graph compressed in a zip file
264+
Download a graph as a zip file
263265

264-
Download a graph compressed in a zip file
266+
Download the compressed graph reference by the hash in a zip file
265267

266268
### Parameters
267269

@@ -417,19 +419,18 @@ Name | Type | Description | Notes
417419

418420
<a name="getDatasetTwingraphStatus"></a>
419421
# **getDatasetTwingraphStatus**
420-
> String getDatasetTwingraphStatus(organization\_id, dataset\_id, job\_id)
422+
> String getDatasetTwingraphStatus(organization\_id, dataset\_id)
421423
422-
Get the status of twingraph import
424+
Get the dataset&#39;s refresh job status
423425

424-
Get the status of a twingraph import
426+
Get the status of the import workflow lauch on the dataset&#39;s refresh.
425427

426428
### Parameters
427429

428430
Name | Type | Description | Notes
429431
------------- | ------------- | ------------- | -------------
430432
**organization\_id** | **String**| the Organization identifier | [default to null]
431433
**dataset\_id** | **String**| the dataset identifier | [default to null]
432-
**job\_id** | **String**| the job identifier | [default to null]
433434

434435
### Return type
435436

@@ -478,9 +479,9 @@ Name | Type | Description | Notes
478479
# **refreshDataset**
479480
> DatasetTwinGraphInfo refreshDataset(organization\_id, dataset\_id)
480481
481-
Refresh dataset
482+
Refresh data on dataset from dataset&#39;s source
482483

483-
Refresh ADT, Storage dataset
484+
Lauch a import from source (ADT or Azure Storage). This replace currently stored data with just extracted data from source.
484485

485486
### Parameters
486487

@@ -559,7 +560,7 @@ null (empty response body)
559560
# **searchDatasets**
560561
> List searchDatasets(organization\_id, DatasetSearch, page, size)
561562
562-
Search Datasets
563+
Search Datasets by tags
563564

564565
### Parameters
565566

@@ -673,7 +674,7 @@ Name | Type | Description | Notes
673674
# **twingraphQuery**
674675
> String twingraphQuery(organization\_id, dataset\_id, DatasetTwinGraphQuery)
675676
676-
Run a query on a graph instance and return the result as a json
677+
Return the result of a query made on the graph instance as a json
677678

678679
Run a query on a graph instance and return the result as a json
679680

@@ -787,9 +788,9 @@ Name | Type | Description | Notes
787788
# **uploadTwingraph**
788789
> uploadTwingraph(organization\_id, dataset\_id, body)
789790
790-
Upload Twingraph with ZIP File
791+
Upload data from zip file to dataset&#39;s twingraph
791792

792-
Upload Twingraph ZIP
793+
To create a new graph from flat files, you need to create a Zip file. This Zip file must countain two folders named Edges and Nodes. .zip hierarchy: *main_folder/Nodes *main_folder/Edges In each folder you can place one or multiple csv files containing your Nodes or Edges data. Your csv files must follow the following header (column name) requirements: The Nodes CSVs requires at least one column (the 1st).Column name &#x3D; &#39;id&#39;. It will represent the nodes ID Ids must be populated with string The Edges CSVs require three columns named, in order, * source * target * id those colomns represent * The source of the edge * The target of the edge * The id of the edge All following columns content are up to you.
793794

794795
### Parameters
795796

doc/Models/SourceInfo.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
66
**name** | **String** | the source name containing the files to import | [optional] [default to null]
77
**location** | **String** | the source location containing the files to import | [default to null]
88
**path** | **String** | the source location containing the files to import | [optional] [default to null]
9+
**jobId** | **String** | indicate the last import jobId | [optional] [default to null]
910

1011
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1112

0 commit comments

Comments
 (0)