Skip to content

Commit

Permalink
Merge pull request #392 from atlanhq/DVX-147
Browse files Browse the repository at this point in the history
Adds option to export only glossaries in asset export basic package
  • Loading branch information
cmgrote authored Dec 23, 2023
2 parents 174ff92 + e83ff0e commit f2f2fce
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 13 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[versions]
jackson = "2.16.0"
slf4j = "2.0.9"
elasticsearch = "8.11.1"
elasticsearch = "8.11.2"
freemarker = "2.3.32"
classgraph = "4.8.165"
testng = "7.8.0"
log4j = "2.22.0"
wiremock = "3.3.1"
jnanoid = "2.0.0"
numaflow = "0.4.8"
awssdk = "2.21.37"
awssdk = "2.21.46"
system-stubs = "2.1.5"
fastcsv = "2.2.2"
poi = "5.2.5"
Expand Down
22 changes: 14 additions & 8 deletions samples/packages/asset-export-basic/src/main/kotlin/Exporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object Exporter {
val assetsQualifiedNamePrefix = Utils.getOrDefault(config.qnPrefix, "default")

val glossaryFile = "$outputDirectory${File.separator}glossary-export.csv"
if (Utils.getOrDefault(config.includeGlossaries, false)) {
if ("GLOSSARIES_ONLY" == assetsExportScope || Utils.getOrDefault(config.includeGlossaries, false)) {
val glossaryExporter = GlossaryExporter(
glossaryFile,
batchSize,
Expand All @@ -28,12 +28,18 @@ object Exporter {
// Still create an (empty) output file, to avoid errors in Argo
File(glossaryFile).createNewFile()
}
val assetExporter = AssetExporter(
"$outputDirectory${File.separator}asset-export.csv",
assetsExportScope,
assetsQualifiedNamePrefix,
batchSize,
)
assetExporter.export()
val assetsFile = "$outputDirectory${File.separator}asset-export.csv"
if ("GLOSSARIES_ONLY" != assetsExportScope) {
val assetExporter = AssetExporter(
assetsFile,
assetsExportScope,
assetsQualifiedNamePrefix,
batchSize,
)
assetExporter.export()
} else {
// Still create an (empty) output file, to avoid errors in Argo
File(assetsFile).createNewFile()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.atlan.Atlan
import com.atlan.pkg.CustomPackage
import com.atlan.pkg.config.model.ui.UIConfig
import com.atlan.pkg.config.model.ui.UIRule
import com.atlan.pkg.config.model.ui.UIStep
import com.atlan.pkg.config.model.workflow.WorkflowOutputs
import com.atlan.pkg.config.widgets.BooleanInput
Expand All @@ -28,6 +29,7 @@ object PackageConfig : CustomPackage(
label = "Export scope",
required = true,
possibleValues = mapOf(
"GLOSSARIES_ONLY" to "Glossaries only",
"ENRICHED_ONLY" to "Enriched only",
"ALL" to "All",
),
Expand All @@ -43,13 +45,23 @@ object PackageConfig : CustomPackage(
),
"include_glossaries" to BooleanInput(
label = "Include glossaries?",
required = true,
required = false,
help = "Whether glossaries (and their terms and categories) should be exported, too.",
grid = 4,
),
),
),
),
rules = listOf(
UIRule(
whenInputs = mapOf("export_scope" to "ENRICHED_ONLY"),
required = listOf("qn_prefix", "include_glossaries"),
),
UIRule(
whenInputs = mapOf("export_scope" to "ALL"),
required = listOf("qn_prefix", "include_glossaries"),
),
),
),
containerImage = "ghcr.io/atlanhq/csa-asset-export-basic:${Atlan.VERSION}",
classToRun = Exporter::class.java,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* SPDX-License-Identifier: Apache-2.0
Copyright 2023 Atlan Pte. Ltd. */
import com.atlan.pkg.PackageTest
import org.testng.ITestContext
import org.testng.annotations.AfterClass
import org.testng.annotations.BeforeClass
import kotlin.test.Test

/**
* Test export of only glossaries, no assets.
*/
class OnlyGlossariesTest : PackageTest() {

private val files = listOf(
"glossary-export.csv",
"debug.log",
"asset-export.csv",
)

@BeforeClass
fun beforeClass() {
setup(
AssetExportBasicCfg(
exportScope = "GLOSSARIES_ONLY",
qnPrefix = "",
includeGlossaries = false,
),
)
Exporter.main(arrayOf(testDirectory))
}

@Test
fun filesCreated() {
validateFilesExist(files.subList(0, files.size - 1))
validateFileExistsButEmpty(files.subList(2, files.size))
}

@Test
fun errorFreeLog() {
validateErrorFreeLog()
}

@AfterClass(alwaysRun = true)
fun afterClass(context: ITestContext) {
teardown(context.failedTests.size() > 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ public AtlanWorkflowPhase monitorStatus(Logger log, Level level) throws AtlanExc
status = runDetails.getStatus();
}
if (log != null) {
log.atLevel(level).log("Workflow status: {}", status);
log.atLevel(level).log("Workflow {}: {}", name, status);
}
} while (status != AtlanWorkflowPhase.SUCCESS
&& status != AtlanWorkflowPhase.ERROR
&& status != AtlanWorkflowPhase.FAILED);
if (log != null) {
log.atLevel(level).log("Workflow completion status: {}", status);
log.atLevel(level).log("Workflow {}: {}", name, status);
}
return status;
} else {
Expand Down

0 comments on commit f2f2fce

Please sign in to comment.