[knext] fix knext config bug (#4)

This commit is contained in:
baifuyu 2023-11-07 18:56:20 +08:00 committed by GitHub
parent ea82b3700b
commit ba5412276b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 21 additions and 9 deletions

View File

@ -154,14 +154,14 @@ public class LocalBuilderExecutorImpl implements LocalBuilderExecutor {
builderStat.success(finalI); builderStat.success(finalI);
} catch (Throwable e) { } catch (Throwable e) {
builderStat.failure(finalI); builderStat.failure(finalI);
log.warn("run buildingJobInstId={} error", jobInst.getJobInstId(), e); log.error("run buildingJobInstId={} error", jobInst.getJobInstId(), e);
} finally { } finally {
if (builderStat.isFinished()) { if (builderStat.isFinished()) {
try { try {
builderMetric.close(); builderMetric.close();
recordCollector.close(); recordCollector.close();
} catch (Throwable e) { } catch (Throwable e) {
log.warn("close builderMetric or recordCollector error", e); log.error("close builderMetric or recordCollector error", e);
} }
} }
} }

View File

@ -35,6 +35,7 @@ import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
@Slf4j @Slf4j
@ -124,6 +125,7 @@ public class ElasticSearchEngineClient extends BaseIdxSearchEngineClient {
configuration.setVariableValue(ElasticSearchConstants.SCHEME, scheme); configuration.setVariableValue(ElasticSearchConstants.SCHEME, scheme);
configuration.setVariableValue(ElasticSearchConstants.HOST, host); configuration.setVariableValue(ElasticSearchConstants.HOST, host);
configuration.setVariableValue(ElasticSearchConstants.PORT, port); configuration.setVariableValue(ElasticSearchConstants.PORT, port);
configuration.setReadTimeout(30, TimeUnit.SECONDS);
configuration.setLogEnabled(false); configuration.setLogEnabled(false);
configuration.setBackendName("httpclient"); configuration.setBackendName("httpclient");
} }

View File

@ -60,6 +60,9 @@ public class ElasticSearchRecordUtils {
for (IdxRecord idxRecord : idxRecords) { for (IdxRecord idxRecord : idxRecords) {
ForestResponse<String> upsert = client.upsert( ForestResponse<String> upsert = client.upsert(
idxName, idxRecord.getDocId(), idxRecord.getFields()); idxName, idxRecord.getDocId(), idxRecord.getFields());
if (upsert.isTimeout()) {
throw new RuntimeException("upsertIdxRecords timeout");
}
if (!upsert.isSuccess()) { if (!upsert.isSuccess()) {
throw new RuntimeException("upsertIdxRecords error, errorMsg=" + upsert.getContent()); throw new RuntimeException("upsertIdxRecords error, errorMsg=" + upsert.getContent());
} }

View File

@ -14,4 +14,4 @@
# #
# mvn clean package -DskipTests # mvn clean package -DskipTests
docker buildx build -f Dockerfile --platform linux/amd64 --push -t baifuyu/openspg:0.0.1-beta1 -t baifuyu/openspg:latest . docker buildx build -f Dockerfile --platform linux/amd64 --push -t baifuyu/openspg:0.0.1-beta2 -t baifuyu/openspg:latest .

View File

@ -1 +1 @@
0.0.1 0.0.1-beta2

View File

@ -1 +1,2 @@
recursive-include knext * recursive-include knext *
recursive-exclude knext/examples *

View File

@ -11,4 +11,4 @@
__package_name__ = "openspg-knext" __package_name__ = "openspg-knext"
__version__ = "0.0.1" __version__ = "0.0.1-beta2"

View File

@ -114,8 +114,10 @@ def _get_cfg_files():
Get global and local knext config files and paths. Get global and local knext config files and paths.
""" """
global_cfg_path = ( global_cfg_path = (
os.environ.get("XDG_CONFIG_HOME") or Path("~/.config").expanduser() Path(os.environ.get("XDG_CONFIG_HOME") or "~/.config").expanduser()
) / ".knext.cfg" ) / ".knext.cfg"
if not global_cfg_path.parent.exists():
Path.mkdir(global_cfg_path.parent)
global_cfg = ConfigParser() global_cfg = ConfigParser()
global_cfg.read(global_cfg_path) global_cfg.read(global_cfg_path)
local_cfg_path = _closest_cfg() local_cfg_path = _closest_cfg()

View File

@ -96,6 +96,11 @@ operator.command("list")(list_operator)
@_main.group() @_main.group()
def project() -> None: def project() -> None:
"""Project client.""" """Project client."""
project_cfg, root_path = get_config()
if project_cfg.has_section("global"):
for cfg in GLOBAL_CONFIG:
os.environ[CFG_PREFIX + cfg.upper()] = project_cfg.get("global", cfg)
pass pass

View File

@ -2,7 +2,6 @@ wget==3.2
pytest==7.4.2 pytest==7.4.2
retrying==1.3.4 retrying==1.3.4
tabulate==0.9.0 tabulate==0.9.0
pemja==0.4.0
jieba==0.42.1 jieba==0.42.1
nltk==3.8.1 nltk==3.8.1
tqdm==4.66.1 tqdm==4.66.1