This is an automated email from the ASF dual-hosted git repository.
yiconghuang pushed a commit to branch chore/relocate-amber
in repository https://gitbox.apache.org/repos/asf/texera.git
The following commit(s) were added to refs/heads/chore/relocate-amber by this
push:
new 7f3da3aa0d fix: get rid of PathUtils
7f3da3aa0d is described below
commit 7f3da3aa0d7f851989bec288b29842507ae09340
Author: Yicong Huang <[email protected]>
AuthorDate: Sun Oct 12 10:20:43 2025 -0700
fix: get rid of PathUtils
---
.../texera/service/AccessControlService.scala | 6 +-
.../org/apache/amber/config/StorageConfig.scala | 3 +-
.../scala/org/apache/amber/util/PathUtils.scala | 84 ----------------------
.../core/storage/model/DatasetFileDocument.scala | 12 +++-
.../org/apache/amber/operator/TestOperators.scala | 11 ++-
.../apache/amber/operator/metadata/OPVersion.java | 4 +-
6 files changed, 20 insertions(+), 100 deletions(-)
diff --git
a/access-control-service/src/main/scala/org/apache/texera/service/AccessControlService.scala
b/access-control-service/src/main/scala/org/apache/texera/service/AccessControlService.scala
index 790d7f56bf..dc71a1aa24 100644
---
a/access-control-service/src/main/scala/org/apache/texera/service/AccessControlService.scala
+++
b/access-control-service/src/main/scala/org/apache/texera/service/AccessControlService.scala
@@ -23,12 +23,13 @@ import io.dropwizard.auth.AuthDynamicFeature
import io.dropwizard.core.Application
import io.dropwizard.core.setup.{Bootstrap, Environment}
import org.apache.amber.config.StorageConfig
-import org.apache.amber.util.PathUtils.accessControlServicePath
import org.apache.texera.auth.{JwtAuthFilter, SessionUser}
import org.apache.texera.dao.SqlServer
import org.apache.texera.service.resource.{AccessControlResource,
HealthCheckResource}
import org.eclipse.jetty.server.session.SessionHandler
+import java.nio.file.Path
+
class AccessControlService extends
Application[AccessControlServiceConfiguration] with LazyLogging {
override def initialize(bootstrap:
Bootstrap[AccessControlServiceConfiguration]): Unit = {
// Register Scala module to Dropwizard default object mapper
@@ -65,7 +66,8 @@ class AccessControlService extends
Application[AccessControlServiceConfiguration
}
object AccessControlService {
def main(args: Array[String]): Unit = {
- val accessControlPath = accessControlServicePath
+ val accessControlPath = Path.of(sys.env.getOrElse("TEXERA_HOME", "."))
+ .resolve("access-control-service")
.resolve("src")
.resolve("main")
.resolve("resources")
diff --git
a/core/config/src/main/scala/org/apache/amber/config/StorageConfig.scala
b/core/config/src/main/scala/org/apache/amber/config/StorageConfig.scala
index 58d1d1739a..81ad85fcaa 100644
--- a/core/config/src/main/scala/org/apache/amber/config/StorageConfig.scala
+++ b/core/config/src/main/scala/org/apache/amber/config/StorageConfig.scala
@@ -20,7 +20,6 @@ package org.apache.amber.config
import com.typesafe.config.{Config, ConfigFactory}
import org.apache.amber.util.ConfigParserUtil.parseSizeStringToBytes
-import org.apache.amber.util.PathUtils.corePath
import java.nio.file.Path
@@ -86,7 +85,7 @@ object StorageConfig {
// File storage configurations
val fileStorageDirectoryPath: Path =
-
corePath.resolve("amber").resolve("user-resources").resolve("workflow-results")
+ Path.of(sys.env.getOrElse("TEXERA_HOME",
".")).resolve("amber").resolve("user-resources").resolve("workflow-results")
// JDBC
val ENV_JDBC_URL = "STORAGE_JDBC_URL"
diff --git a/core/config/src/main/scala/org/apache/amber/util/PathUtils.scala
b/core/config/src/main/scala/org/apache/amber/util/PathUtils.scala
deleted file mode 100644
index f3a433c7b5..0000000000
--- a/core/config/src/main/scala/org/apache/amber/util/PathUtils.scala
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.amber.util
-
-import java.nio.file.{Files, Path, Paths}
-import scala.jdk.CollectionConverters.IteratorHasAsScala
-
-object PathUtils {
- val coreDirectoryName = "core"
-
- /**
- * Gets the real path of the workflow-compiling-service home directory by:
- * 1) Checking if the current directory is workflow-compiling-service.
- * If it's not, then:
- * 2) Searching the siblings and children to find the home path.
- *
- * @return the real absolute path to the home directory
- */
- lazy val corePath: Path = {
- val currentWorkingDirectory = Paths.get(".").toRealPath()
- // check if the current directory is the home path
- if (isCorePath(currentWorkingDirectory)) {
- currentWorkingDirectory
- } else {
- // from current path's parent directory, search its children to find
home path
- val searchChildren = Files
- .walk(currentWorkingDirectory.getParent, 3)
- .filter((path: Path) => isCorePath(path))
- .findAny
- if (searchChildren.isPresent) {
- searchChildren.get
- } else {
- throw new RuntimeException(
- f"Finding $coreDirectoryName home path failed. Current working
directory is " + currentWorkingDirectory
- )
- }
- }
- }
-
- lazy val accessControlServicePath: Path =
corePath.resolve("access-control-service")
-
- private lazy val datasetsRootPath =
- corePath.resolve("amber").resolve("user-resources").resolve("datasets")
-
- def getDatasetPath(did: Integer): Path = {
- datasetsRootPath.resolve(did.toString)
- }
-
- lazy val gitDirectoryPath: Path = corePath.getParent
-
- def getAllDatasetDirectories(): List[Path] = {
- if (Files.exists(datasetsRootPath)) {
- Files
- .list(datasetsRootPath)
- .filter(Files.isDirectory(_))
- .iterator()
- .asScala
- .toList
- } else {
- List.empty[Path]
- }
- }
-
- private def isCorePath(path: Path): Boolean = {
- path.toRealPath().endsWith(coreDirectoryName)
- }
-}
diff --git
a/core/workflow-core/src/main/scala/org/apache/amber/core/storage/model/DatasetFileDocument.scala
b/core/workflow-core/src/main/scala/org/apache/amber/core/storage/model/DatasetFileDocument.scala
index 8a25735b89..0b167ca87c 100644
---
a/core/workflow-core/src/main/scala/org/apache/amber/core/storage/model/DatasetFileDocument.scala
+++
b/core/workflow-core/src/main/scala/org/apache/amber/core/storage/model/DatasetFileDocument.scala
@@ -27,7 +27,6 @@ import
org.apache.amber.core.storage.model.DatasetFileDocument.{
}
import org.apache.amber.core.storage.util.LakeFSStorageClient
import
org.apache.amber.core.storage.util.dataset.GitVersionControlLocalFileStorage
-import org.apache.amber.util.PathUtils
import java.io.{File, FileOutputStream, InputStream}
import java.net._
@@ -169,10 +168,17 @@ private[storage] class DatasetFileDocument(uri: URI)
case Some(file) => Files.delete(file.toPath)
case None => // Do nothing
}
+ lazy val datasetsRootPath =
+ Path.of(sys.env.getOrElse("TEXERA_HOME",
".")).resolve("amber").resolve("user-resources").resolve("datasets")
+
+ def getDatasetPath(did: Integer): Path = {
+ datasetsRootPath.resolve(did.toString)
+ }
+
// then remove the dataset file
GitVersionControlLocalFileStorage.removeFileFromRepo(
- PathUtils.getDatasetPath(0),
- PathUtils.getDatasetPath(0).resolve(fileRelativePath)
+ getDatasetPath(0),
+ getDatasetPath(0).resolve(fileRelativePath)
)
}
diff --git
a/core/workflow-operator/src/main/scala/org/apache/amber/operator/TestOperators.scala
b/core/workflow-operator/src/main/scala/org/apache/amber/operator/TestOperators.scala
index da2d579d47..7d9c898553 100644
---
a/core/workflow-operator/src/main/scala/org/apache/amber/operator/TestOperators.scala
+++
b/core/workflow-operator/src/main/scala/org/apache/amber/operator/TestOperators.scala
@@ -20,11 +20,7 @@
package org.apache.amber.operator
import org.apache.amber.core.storage.FileResolver
-import org.apache.amber.operator.aggregate.{
- AggregateOpDesc,
- AggregationFunction,
- AggregationOperation
-}
+import org.apache.amber.operator.aggregate.{AggregateOpDesc,
AggregationFunction, AggregationOperation}
import org.apache.amber.operator.hashJoin.HashJoinOpDesc
import org.apache.amber.operator.keywordSearch.KeywordSearchOpDesc
import org.apache.amber.operator.source.scan.csv.CSVScanSourceOpDesc
@@ -32,11 +28,12 @@ import
org.apache.amber.operator.source.scan.json.JSONLScanSourceOpDesc
import org.apache.amber.operator.source.sql.asterixdb.AsterixDBSourceOpDesc
import org.apache.amber.operator.source.sql.mysql.MySQLSourceOpDesc
import org.apache.amber.operator.udf.python.PythonUDFOpDescV2
-import org.apache.amber.util.PathUtils
+
+import java.nio.file.Path
object TestOperators {
- val parentDir =
PathUtils.corePath.resolve("workflow-operator").toRealPath().toString
+ val parentDir = Path.of(sys.env.getOrElse("TEXERA_HOME",
".")).resolve("workflow-operator").toRealPath().toString
val CountrySalesSmallCsvPath =
s"$parentDir/src/test/resources/country_sales_small.csv"
val CountrySalesMediumCsvPath =
s"$parentDir/src/test/resources/country_sales_medium.csv"
val CountrySalesHeaderlessSmallCsvPath =
diff --git
a/core/workflow-operator/src/main/scala/org/apache/amber/operator/metadata/OPVersion.java
b/core/workflow-operator/src/main/scala/org/apache/amber/operator/metadata/OPVersion.java
index 46c75e01e0..3d2adae23a 100644
---
a/core/workflow-operator/src/main/scala/org/apache/amber/operator/metadata/OPVersion.java
+++
b/core/workflow-operator/src/main/scala/org/apache/amber/operator/metadata/OPVersion.java
@@ -19,12 +19,12 @@
package org.apache.amber.operator.metadata;
-import org.apache.amber.util.PathUtils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
@@ -33,7 +33,7 @@ public class OPVersion {
private static Map<String, String> opMap = new HashMap<>();
static {
try {
- git = Git.open(new File(PathUtils.gitDirectoryPath().toString()));
+ git = Git.open(new
File(Path.of(System.getenv().getOrDefault("TEXERA_HOME", ".")).toString()));
} catch (IOException e) {
e.printStackTrace();
}