status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
⌀ | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
unknown | language
stringclasses 5
values | commit_datetime
unknown | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 14,699 | sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. | ### Issue you'd like to raise.
what is this issue, and how can i resolve it:
```python
os.environ["AZURE_OPENAI_API_KEY"] = AZURE_OPENAI_API_KEY
os.environ["AZURE_OPENAI_ENDPOINT"] = AZURE_OPENAI_ENDPOINT
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-05-15"
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
embedding = OpenAIEmbeddings()
COLLECTION_NAME = "network_team_documents"
CONNECTION_STRING = PGVector.connection_string_from_db_params(
driver=os.environ.get(DB_DRIVER, DB_DRIVER),
host=os.environ.get(DB_HOST, DB_HOST),
port=int(os.environ.get(DB_PORT, DB_PORT)),
database=os.environ.get(DB_DB, DB_DB),
user=os.environ.get(DB_USER, DB_USER),
password=os.environ.get(DB_PASS, DB_PASS),
)
store = PGVector(
collection_name=COLLECTION_NAME,
connection_string=CONNECTION_STRING,
embedding_function=embedding,
extend_existing=True,
)
gpt4 = AzureChatOpenAI(
azure_deployment="GPT4",
openai_api_version="2023-05-15",
)
retriever = store.as_retriever(search_type="similarity", search_kwargs={"k": 10})
qa_chain = RetrievalQA.from_chain_type(llm=gpt4,
chain_type="stuff",
retriever=retriever,
return_source_documents=True)
return qa_chain
```
```python
Traceback (most recent call last):
File "/opt/network_tool/chatbot/views.py", line 21, in chat
chat_object = create_session()
File "/opt/network_tool/chatbot/chatbot_functions.py", line 95, in create_session
store = PGVector(
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 199, in __init__
self.__post_init__()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 207, in __post_init__
EmbeddingStore, CollectionStore = _get_embedding_collection_store()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 66, in _get_embedding_collection_store
class CollectionStore(BaseModel):
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_api.py", line 195, in __init__
_as_declarative(reg, cls, dict_)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 247, in _as_declarative
return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 328, in setup_mapping
return _ClassScanMapperConfig(
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 578, in __init__
self._setup_table(table)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1729, in _setup_table
table_cls(
File "", line 2, in __new__
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 436, in __new__
return cls._new(*args, **kw)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 468, in _new
raise exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
```
### Suggestion:
_No response_ | https://github.com/langchain-ai/langchain/issues/14699 | https://github.com/langchain-ai/langchain/pull/14726 | 1cec0afc62697ee730aa1378b69ab4556ffecffc | 9fb26a2a718bc18a5ce48f04cf6b66bc4751b734 | "2023-12-14T06:51:40Z" | python | "2023-12-14T21:27:30Z" | libs/community/langchain_community/vectorstores/pgvector.py | connection_string: str = get_from_dict_or_env(
data=kwargs,
key="connection_string",
env_key="PGVECTOR_CONNECTION_STRING",
)
if not connection_string:
raise ValueError(
"Postgres connection string is required"
"Either pass it as a parameter"
"or set the PGVECTOR_CONNECTION_STRING environment variable."
)
return connection_string
@classmethod
def from_documents( |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 14,699 | sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. | ### Issue you'd like to raise.
what is this issue, and how can i resolve it:
```python
os.environ["AZURE_OPENAI_API_KEY"] = AZURE_OPENAI_API_KEY
os.environ["AZURE_OPENAI_ENDPOINT"] = AZURE_OPENAI_ENDPOINT
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-05-15"
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
embedding = OpenAIEmbeddings()
COLLECTION_NAME = "network_team_documents"
CONNECTION_STRING = PGVector.connection_string_from_db_params(
driver=os.environ.get(DB_DRIVER, DB_DRIVER),
host=os.environ.get(DB_HOST, DB_HOST),
port=int(os.environ.get(DB_PORT, DB_PORT)),
database=os.environ.get(DB_DB, DB_DB),
user=os.environ.get(DB_USER, DB_USER),
password=os.environ.get(DB_PASS, DB_PASS),
)
store = PGVector(
collection_name=COLLECTION_NAME,
connection_string=CONNECTION_STRING,
embedding_function=embedding,
extend_existing=True,
)
gpt4 = AzureChatOpenAI(
azure_deployment="GPT4",
openai_api_version="2023-05-15",
)
retriever = store.as_retriever(search_type="similarity", search_kwargs={"k": 10})
qa_chain = RetrievalQA.from_chain_type(llm=gpt4,
chain_type="stuff",
retriever=retriever,
return_source_documents=True)
return qa_chain
```
```python
Traceback (most recent call last):
File "/opt/network_tool/chatbot/views.py", line 21, in chat
chat_object = create_session()
File "/opt/network_tool/chatbot/chatbot_functions.py", line 95, in create_session
store = PGVector(
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 199, in __init__
self.__post_init__()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 207, in __post_init__
EmbeddingStore, CollectionStore = _get_embedding_collection_store()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 66, in _get_embedding_collection_store
class CollectionStore(BaseModel):
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_api.py", line 195, in __init__
_as_declarative(reg, cls, dict_)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 247, in _as_declarative
return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 328, in setup_mapping
return _ClassScanMapperConfig(
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 578, in __init__
self._setup_table(table)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1729, in _setup_table
table_cls(
File "", line 2, in __new__
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 436, in __new__
return cls._new(*args, **kw)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 468, in _new
raise exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
```
### Suggestion:
_No response_ | https://github.com/langchain-ai/langchain/issues/14699 | https://github.com/langchain-ai/langchain/pull/14726 | 1cec0afc62697ee730aa1378b69ab4556ffecffc | 9fb26a2a718bc18a5ce48f04cf6b66bc4751b734 | "2023-12-14T06:51:40Z" | python | "2023-12-14T21:27:30Z" | libs/community/langchain_community/vectorstores/pgvector.py | cls: Type[PGVector],
documents: List[Document],
embedding: Embeddings,
collection_name: str = _LANGCHAIN_DEFAULT_COLLECTION_NAME,
distance_strategy: DistanceStrategy = DEFAULT_DISTANCE_STRATEGY,
ids: Optional[List[str]] = None,
pre_delete_collection: bool = False,
**kwargs: Any,
) -> PGVector:
"""
Return VectorStore initialized from documents and embeddings.
Postgres connection string is required
"Either pass it as a parameter
or set the PGVECTOR_CONNECTION_STRING environment variable.
"""
texts = [d.page_content for d in documents]
metadatas = [d.metadata for d in documents]
connection_string = cls.get_connection_string(kwargs)
kwargs["connection_string"] = connection_string
return cls.from_texts(
texts=texts,
pre_delete_collection=pre_delete_collection, |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 14,699 | sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. | ### Issue you'd like to raise.
what is this issue, and how can i resolve it:
```python
os.environ["AZURE_OPENAI_API_KEY"] = AZURE_OPENAI_API_KEY
os.environ["AZURE_OPENAI_ENDPOINT"] = AZURE_OPENAI_ENDPOINT
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-05-15"
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
embedding = OpenAIEmbeddings()
COLLECTION_NAME = "network_team_documents"
CONNECTION_STRING = PGVector.connection_string_from_db_params(
driver=os.environ.get(DB_DRIVER, DB_DRIVER),
host=os.environ.get(DB_HOST, DB_HOST),
port=int(os.environ.get(DB_PORT, DB_PORT)),
database=os.environ.get(DB_DB, DB_DB),
user=os.environ.get(DB_USER, DB_USER),
password=os.environ.get(DB_PASS, DB_PASS),
)
store = PGVector(
collection_name=COLLECTION_NAME,
connection_string=CONNECTION_STRING,
embedding_function=embedding,
extend_existing=True,
)
gpt4 = AzureChatOpenAI(
azure_deployment="GPT4",
openai_api_version="2023-05-15",
)
retriever = store.as_retriever(search_type="similarity", search_kwargs={"k": 10})
qa_chain = RetrievalQA.from_chain_type(llm=gpt4,
chain_type="stuff",
retriever=retriever,
return_source_documents=True)
return qa_chain
```
```python
Traceback (most recent call last):
File "/opt/network_tool/chatbot/views.py", line 21, in chat
chat_object = create_session()
File "/opt/network_tool/chatbot/chatbot_functions.py", line 95, in create_session
store = PGVector(
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 199, in __init__
self.__post_init__()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 207, in __post_init__
EmbeddingStore, CollectionStore = _get_embedding_collection_store()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 66, in _get_embedding_collection_store
class CollectionStore(BaseModel):
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_api.py", line 195, in __init__
_as_declarative(reg, cls, dict_)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 247, in _as_declarative
return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 328, in setup_mapping
return _ClassScanMapperConfig(
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 578, in __init__
self._setup_table(table)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1729, in _setup_table
table_cls(
File "", line 2, in __new__
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 436, in __new__
return cls._new(*args, **kw)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 468, in _new
raise exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
```
### Suggestion:
_No response_ | https://github.com/langchain-ai/langchain/issues/14699 | https://github.com/langchain-ai/langchain/pull/14726 | 1cec0afc62697ee730aa1378b69ab4556ffecffc | 9fb26a2a718bc18a5ce48f04cf6b66bc4751b734 | "2023-12-14T06:51:40Z" | python | "2023-12-14T21:27:30Z" | libs/community/langchain_community/vectorstores/pgvector.py | embedding=embedding,
distance_strategy=distance_strategy,
metadatas=metadatas,
ids=ids,
collection_name=collection_name,
**kwargs,
)
@classmethod
def connection_string_from_db_params(
cls,
driver: str,
host: str,
port: int,
database: str,
user: str,
password: str,
) -> str:
"""Return connection string from database parameters."""
return f"postgresql+{driver}://{user}:{password}@{host}:{port}/{database}"
def _select_relevance_score_fn(self) -> Callable[[float], float]:
"""
The 'correct' relevance function
may differ depending on a few things, including:
- the distance / similarity metric used by the VectorStore
- the scale of your embeddings (OpenAI's are unit normed. Many others are not!)
- embedding dimensionality
- etc.
"""
if self.override_relevance_score_fn is not None:
return self.override_relevance_score_fn |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 14,699 | sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. | ### Issue you'd like to raise.
what is this issue, and how can i resolve it:
```python
os.environ["AZURE_OPENAI_API_KEY"] = AZURE_OPENAI_API_KEY
os.environ["AZURE_OPENAI_ENDPOINT"] = AZURE_OPENAI_ENDPOINT
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-05-15"
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
embedding = OpenAIEmbeddings()
COLLECTION_NAME = "network_team_documents"
CONNECTION_STRING = PGVector.connection_string_from_db_params(
driver=os.environ.get(DB_DRIVER, DB_DRIVER),
host=os.environ.get(DB_HOST, DB_HOST),
port=int(os.environ.get(DB_PORT, DB_PORT)),
database=os.environ.get(DB_DB, DB_DB),
user=os.environ.get(DB_USER, DB_USER),
password=os.environ.get(DB_PASS, DB_PASS),
)
store = PGVector(
collection_name=COLLECTION_NAME,
connection_string=CONNECTION_STRING,
embedding_function=embedding,
extend_existing=True,
)
gpt4 = AzureChatOpenAI(
azure_deployment="GPT4",
openai_api_version="2023-05-15",
)
retriever = store.as_retriever(search_type="similarity", search_kwargs={"k": 10})
qa_chain = RetrievalQA.from_chain_type(llm=gpt4,
chain_type="stuff",
retriever=retriever,
return_source_documents=True)
return qa_chain
```
```python
Traceback (most recent call last):
File "/opt/network_tool/chatbot/views.py", line 21, in chat
chat_object = create_session()
File "/opt/network_tool/chatbot/chatbot_functions.py", line 95, in create_session
store = PGVector(
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 199, in __init__
self.__post_init__()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 207, in __post_init__
EmbeddingStore, CollectionStore = _get_embedding_collection_store()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 66, in _get_embedding_collection_store
class CollectionStore(BaseModel):
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_api.py", line 195, in __init__
_as_declarative(reg, cls, dict_)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 247, in _as_declarative
return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 328, in setup_mapping
return _ClassScanMapperConfig(
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 578, in __init__
self._setup_table(table)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1729, in _setup_table
table_cls(
File "", line 2, in __new__
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 436, in __new__
return cls._new(*args, **kw)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 468, in _new
raise exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
```
### Suggestion:
_No response_ | https://github.com/langchain-ai/langchain/issues/14699 | https://github.com/langchain-ai/langchain/pull/14726 | 1cec0afc62697ee730aa1378b69ab4556ffecffc | 9fb26a2a718bc18a5ce48f04cf6b66bc4751b734 | "2023-12-14T06:51:40Z" | python | "2023-12-14T21:27:30Z" | libs/community/langchain_community/vectorstores/pgvector.py | if self._distance_strategy == DistanceStrategy.COSINE:
return self._cosine_relevance_score_fn
elif self._distance_strategy == DistanceStrategy.EUCLIDEAN:
return self._euclidean_relevance_score_fn
elif self._distance_strategy == DistanceStrategy.MAX_INNER_PRODUCT:
return self._max_inner_product_relevance_score_fn
else:
raise ValueError(
"No supported normalization function"
f" for distance_strategy of {self._distance_strategy}."
"Consider providing relevance_score_fn to PGVector constructor."
)
def max_marginal_relevance_search_with_score_by_vector(
self,
embedding: List[float],
k: int = 4,
fetch_k: int = 20,
lambda_mult: float = 0.5,
filter: Optional[Dict[str, str]] = None,
**kwargs: Any,
) -> List[Tuple[Document, float]]:
"""Return docs selected using the maximal marginal relevance with score
to embedding vector.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.
Args:
embedding: Embedding to look up documents similar to.
k (int): Number of Documents to return. Defaults to 4. |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 14,699 | sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. | ### Issue you'd like to raise.
what is this issue, and how can i resolve it:
```python
os.environ["AZURE_OPENAI_API_KEY"] = AZURE_OPENAI_API_KEY
os.environ["AZURE_OPENAI_ENDPOINT"] = AZURE_OPENAI_ENDPOINT
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-05-15"
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
embedding = OpenAIEmbeddings()
COLLECTION_NAME = "network_team_documents"
CONNECTION_STRING = PGVector.connection_string_from_db_params(
driver=os.environ.get(DB_DRIVER, DB_DRIVER),
host=os.environ.get(DB_HOST, DB_HOST),
port=int(os.environ.get(DB_PORT, DB_PORT)),
database=os.environ.get(DB_DB, DB_DB),
user=os.environ.get(DB_USER, DB_USER),
password=os.environ.get(DB_PASS, DB_PASS),
)
store = PGVector(
collection_name=COLLECTION_NAME,
connection_string=CONNECTION_STRING,
embedding_function=embedding,
extend_existing=True,
)
gpt4 = AzureChatOpenAI(
azure_deployment="GPT4",
openai_api_version="2023-05-15",
)
retriever = store.as_retriever(search_type="similarity", search_kwargs={"k": 10})
qa_chain = RetrievalQA.from_chain_type(llm=gpt4,
chain_type="stuff",
retriever=retriever,
return_source_documents=True)
return qa_chain
```
```python
Traceback (most recent call last):
File "/opt/network_tool/chatbot/views.py", line 21, in chat
chat_object = create_session()
File "/opt/network_tool/chatbot/chatbot_functions.py", line 95, in create_session
store = PGVector(
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 199, in __init__
self.__post_init__()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 207, in __post_init__
EmbeddingStore, CollectionStore = _get_embedding_collection_store()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 66, in _get_embedding_collection_store
class CollectionStore(BaseModel):
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_api.py", line 195, in __init__
_as_declarative(reg, cls, dict_)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 247, in _as_declarative
return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 328, in setup_mapping
return _ClassScanMapperConfig(
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 578, in __init__
self._setup_table(table)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1729, in _setup_table
table_cls(
File "", line 2, in __new__
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 436, in __new__
return cls._new(*args, **kw)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 468, in _new
raise exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
```
### Suggestion:
_No response_ | https://github.com/langchain-ai/langchain/issues/14699 | https://github.com/langchain-ai/langchain/pull/14726 | 1cec0afc62697ee730aa1378b69ab4556ffecffc | 9fb26a2a718bc18a5ce48f04cf6b66bc4751b734 | "2023-12-14T06:51:40Z" | python | "2023-12-14T21:27:30Z" | libs/community/langchain_community/vectorstores/pgvector.py | fetch_k (int): Number of Documents to fetch to pass to MMR algorithm.
Defaults to 20.
lambda_mult (float): Number between 0 and 1 that determines the degree
of diversity among the results with 0 corresponding
to maximum diversity and 1 to minimum diversity.
Defaults to 0.5.
filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None.
Returns:
List[Tuple[Document, float]]: List of Documents selected by maximal marginal
relevance to the query and score for each.
"""
results = self.__query_collection(embedding=embedding, k=fetch_k, filter=filter)
embedding_list = [result.EmbeddingStore.embedding for result in results]
mmr_selected = maximal_marginal_relevance(
np.array(embedding, dtype=np.float32),
embedding_list,
k=k,
lambda_mult=lambda_mult,
)
candidates = self._results_to_docs_and_scores(results)
return [r for i, r in enumerate(candidates) if i in mmr_selected]
def max_marginal_relevance_search(
self,
query: str,
k: int = 4,
fetch_k: int = 20,
lambda_mult: float = 0.5,
filter: Optional[Dict[str, str]] = None,
**kwargs: Any,
) -> List[Document]: |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 14,699 | sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. | ### Issue you'd like to raise.
what is this issue, and how can i resolve it:
```python
os.environ["AZURE_OPENAI_API_KEY"] = AZURE_OPENAI_API_KEY
os.environ["AZURE_OPENAI_ENDPOINT"] = AZURE_OPENAI_ENDPOINT
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-05-15"
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
embedding = OpenAIEmbeddings()
COLLECTION_NAME = "network_team_documents"
CONNECTION_STRING = PGVector.connection_string_from_db_params(
driver=os.environ.get(DB_DRIVER, DB_DRIVER),
host=os.environ.get(DB_HOST, DB_HOST),
port=int(os.environ.get(DB_PORT, DB_PORT)),
database=os.environ.get(DB_DB, DB_DB),
user=os.environ.get(DB_USER, DB_USER),
password=os.environ.get(DB_PASS, DB_PASS),
)
store = PGVector(
collection_name=COLLECTION_NAME,
connection_string=CONNECTION_STRING,
embedding_function=embedding,
extend_existing=True,
)
gpt4 = AzureChatOpenAI(
azure_deployment="GPT4",
openai_api_version="2023-05-15",
)
retriever = store.as_retriever(search_type="similarity", search_kwargs={"k": 10})
qa_chain = RetrievalQA.from_chain_type(llm=gpt4,
chain_type="stuff",
retriever=retriever,
return_source_documents=True)
return qa_chain
```
```python
Traceback (most recent call last):
File "/opt/network_tool/chatbot/views.py", line 21, in chat
chat_object = create_session()
File "/opt/network_tool/chatbot/chatbot_functions.py", line 95, in create_session
store = PGVector(
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 199, in __init__
self.__post_init__()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 207, in __post_init__
EmbeddingStore, CollectionStore = _get_embedding_collection_store()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 66, in _get_embedding_collection_store
class CollectionStore(BaseModel):
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_api.py", line 195, in __init__
_as_declarative(reg, cls, dict_)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 247, in _as_declarative
return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 328, in setup_mapping
return _ClassScanMapperConfig(
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 578, in __init__
self._setup_table(table)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1729, in _setup_table
table_cls(
File "", line 2, in __new__
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 436, in __new__
return cls._new(*args, **kw)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 468, in _new
raise exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
```
### Suggestion:
_No response_ | https://github.com/langchain-ai/langchain/issues/14699 | https://github.com/langchain-ai/langchain/pull/14726 | 1cec0afc62697ee730aa1378b69ab4556ffecffc | 9fb26a2a718bc18a5ce48f04cf6b66bc4751b734 | "2023-12-14T06:51:40Z" | python | "2023-12-14T21:27:30Z" | libs/community/langchain_community/vectorstores/pgvector.py | """Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.
Args:
query (str): Text to look up documents similar to.
k (int): Number of Documents to return. Defaults to 4.
fetch_k (int): Number of Documents to fetch to pass to MMR algorithm.
Defaults to 20.
lambda_mult (float): Number between 0 and 1 that determines the degree
of diversity among the results with 0 corresponding
to maximum diversity and 1 to minimum diversity.
Defaults to 0.5.
filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None.
Returns:
List[Document]: List of Documents selected by maximal marginal relevance.
"""
embedding = self.embedding_function.embed_query(query)
return self.max_marginal_relevance_search_by_vector(
embedding,
k=k,
fetch_k=fetch_k,
lambda_mult=lambda_mult,
filter=filter,
**kwargs,
)
def max_marginal_relevance_search_with_score(
self,
query: str,
k: int = 4,
fetch_k: int = 20, |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 14,699 | sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. | ### Issue you'd like to raise.
what is this issue, and how can i resolve it:
```python
os.environ["AZURE_OPENAI_API_KEY"] = AZURE_OPENAI_API_KEY
os.environ["AZURE_OPENAI_ENDPOINT"] = AZURE_OPENAI_ENDPOINT
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-05-15"
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
embedding = OpenAIEmbeddings()
COLLECTION_NAME = "network_team_documents"
CONNECTION_STRING = PGVector.connection_string_from_db_params(
driver=os.environ.get(DB_DRIVER, DB_DRIVER),
host=os.environ.get(DB_HOST, DB_HOST),
port=int(os.environ.get(DB_PORT, DB_PORT)),
database=os.environ.get(DB_DB, DB_DB),
user=os.environ.get(DB_USER, DB_USER),
password=os.environ.get(DB_PASS, DB_PASS),
)
store = PGVector(
collection_name=COLLECTION_NAME,
connection_string=CONNECTION_STRING,
embedding_function=embedding,
extend_existing=True,
)
gpt4 = AzureChatOpenAI(
azure_deployment="GPT4",
openai_api_version="2023-05-15",
)
retriever = store.as_retriever(search_type="similarity", search_kwargs={"k": 10})
qa_chain = RetrievalQA.from_chain_type(llm=gpt4,
chain_type="stuff",
retriever=retriever,
return_source_documents=True)
return qa_chain
```
```python
Traceback (most recent call last):
File "/opt/network_tool/chatbot/views.py", line 21, in chat
chat_object = create_session()
File "/opt/network_tool/chatbot/chatbot_functions.py", line 95, in create_session
store = PGVector(
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 199, in __init__
self.__post_init__()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 207, in __post_init__
EmbeddingStore, CollectionStore = _get_embedding_collection_store()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 66, in _get_embedding_collection_store
class CollectionStore(BaseModel):
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_api.py", line 195, in __init__
_as_declarative(reg, cls, dict_)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 247, in _as_declarative
return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 328, in setup_mapping
return _ClassScanMapperConfig(
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 578, in __init__
self._setup_table(table)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1729, in _setup_table
table_cls(
File "", line 2, in __new__
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 436, in __new__
return cls._new(*args, **kw)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 468, in _new
raise exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
```
### Suggestion:
_No response_ | https://github.com/langchain-ai/langchain/issues/14699 | https://github.com/langchain-ai/langchain/pull/14726 | 1cec0afc62697ee730aa1378b69ab4556ffecffc | 9fb26a2a718bc18a5ce48f04cf6b66bc4751b734 | "2023-12-14T06:51:40Z" | python | "2023-12-14T21:27:30Z" | libs/community/langchain_community/vectorstores/pgvector.py | lambda_mult: float = 0.5,
filter: Optional[dict] = None,
**kwargs: Any,
) -> List[Tuple[Document, float]]:
"""Return docs selected using the maximal marginal relevance with score.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.
Args:
query (str): Text to look up documents similar to.
k (int): Number of Documents to return. Defaults to 4.
fetch_k (int): Number of Documents to fetch to pass to MMR algorithm.
Defaults to 20.
lambda_mult (float): Number between 0 and 1 that determines the degree
of diversity among the results with 0 corresponding
to maximum diversity and 1 to minimum diversity.
Defaults to 0.5.
filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None.
Returns:
List[Tuple[Document, float]]: List of Documents selected by maximal marginal
relevance to the query and score for each.
"""
embedding = self.embedding_function.embed_query(query)
docs = self.max_marginal_relevance_search_with_score_by_vector(
embedding=embedding,
k=k,
fetch_k=fetch_k,
lambda_mult=lambda_mult,
filter=filter,
**kwargs,
) |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 14,699 | sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. | ### Issue you'd like to raise.
what is this issue, and how can i resolve it:
```python
os.environ["AZURE_OPENAI_API_KEY"] = AZURE_OPENAI_API_KEY
os.environ["AZURE_OPENAI_ENDPOINT"] = AZURE_OPENAI_ENDPOINT
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-05-15"
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
embedding = OpenAIEmbeddings()
COLLECTION_NAME = "network_team_documents"
CONNECTION_STRING = PGVector.connection_string_from_db_params(
driver=os.environ.get(DB_DRIVER, DB_DRIVER),
host=os.environ.get(DB_HOST, DB_HOST),
port=int(os.environ.get(DB_PORT, DB_PORT)),
database=os.environ.get(DB_DB, DB_DB),
user=os.environ.get(DB_USER, DB_USER),
password=os.environ.get(DB_PASS, DB_PASS),
)
store = PGVector(
collection_name=COLLECTION_NAME,
connection_string=CONNECTION_STRING,
embedding_function=embedding,
extend_existing=True,
)
gpt4 = AzureChatOpenAI(
azure_deployment="GPT4",
openai_api_version="2023-05-15",
)
retriever = store.as_retriever(search_type="similarity", search_kwargs={"k": 10})
qa_chain = RetrievalQA.from_chain_type(llm=gpt4,
chain_type="stuff",
retriever=retriever,
return_source_documents=True)
return qa_chain
```
```python
Traceback (most recent call last):
File "/opt/network_tool/chatbot/views.py", line 21, in chat
chat_object = create_session()
File "/opt/network_tool/chatbot/chatbot_functions.py", line 95, in create_session
store = PGVector(
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 199, in __init__
self.__post_init__()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 207, in __post_init__
EmbeddingStore, CollectionStore = _get_embedding_collection_store()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 66, in _get_embedding_collection_store
class CollectionStore(BaseModel):
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_api.py", line 195, in __init__
_as_declarative(reg, cls, dict_)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 247, in _as_declarative
return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 328, in setup_mapping
return _ClassScanMapperConfig(
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 578, in __init__
self._setup_table(table)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1729, in _setup_table
table_cls(
File "", line 2, in __new__
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 436, in __new__
return cls._new(*args, **kw)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 468, in _new
raise exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
```
### Suggestion:
_No response_ | https://github.com/langchain-ai/langchain/issues/14699 | https://github.com/langchain-ai/langchain/pull/14726 | 1cec0afc62697ee730aa1378b69ab4556ffecffc | 9fb26a2a718bc18a5ce48f04cf6b66bc4751b734 | "2023-12-14T06:51:40Z" | python | "2023-12-14T21:27:30Z" | libs/community/langchain_community/vectorstores/pgvector.py | return docs
def max_marginal_relevance_search_by_vector(
self,
embedding: List[float],
k: int = 4,
fetch_k: int = 20,
lambda_mult: float = 0.5,
filter: Optional[Dict[str, str]] = None,
**kwargs: Any,
) -> List[Document]:
"""Return docs selected using the maximal marginal relevance
to embedding vector.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.
Args:
embedding (str): Text to look up documents similar to.
k (int): Number of Documents to return. Defaults to 4.
fetch_k (int): Number of Documents to fetch to pass to MMR algorithm.
Defaults to 20.
lambda_mult (float): Number between 0 and 1 that determines the degree
of diversity among the results with 0 corresponding
to maximum diversity and 1 to minimum diversity.
Defaults to 0.5.
filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None.
Returns:
List[Document]: List of Documents selected by maximal marginal relevance.
"""
docs_and_scores = self.max_marginal_relevance_search_with_score_by_vector(
embedding,
k=k, |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 14,699 | sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. | ### Issue you'd like to raise.
what is this issue, and how can i resolve it:
```python
os.environ["AZURE_OPENAI_API_KEY"] = AZURE_OPENAI_API_KEY
os.environ["AZURE_OPENAI_ENDPOINT"] = AZURE_OPENAI_ENDPOINT
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-05-15"
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
embedding = OpenAIEmbeddings()
COLLECTION_NAME = "network_team_documents"
CONNECTION_STRING = PGVector.connection_string_from_db_params(
driver=os.environ.get(DB_DRIVER, DB_DRIVER),
host=os.environ.get(DB_HOST, DB_HOST),
port=int(os.environ.get(DB_PORT, DB_PORT)),
database=os.environ.get(DB_DB, DB_DB),
user=os.environ.get(DB_USER, DB_USER),
password=os.environ.get(DB_PASS, DB_PASS),
)
store = PGVector(
collection_name=COLLECTION_NAME,
connection_string=CONNECTION_STRING,
embedding_function=embedding,
extend_existing=True,
)
gpt4 = AzureChatOpenAI(
azure_deployment="GPT4",
openai_api_version="2023-05-15",
)
retriever = store.as_retriever(search_type="similarity", search_kwargs={"k": 10})
qa_chain = RetrievalQA.from_chain_type(llm=gpt4,
chain_type="stuff",
retriever=retriever,
return_source_documents=True)
return qa_chain
```
```python
Traceback (most recent call last):
File "/opt/network_tool/chatbot/views.py", line 21, in chat
chat_object = create_session()
File "/opt/network_tool/chatbot/chatbot_functions.py", line 95, in create_session
store = PGVector(
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 199, in __init__
self.__post_init__()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 207, in __post_init__
EmbeddingStore, CollectionStore = _get_embedding_collection_store()
File "/opt/klevernet_venv/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py", line 66, in _get_embedding_collection_store
class CollectionStore(BaseModel):
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_api.py", line 195, in __init__
_as_declarative(reg, cls, dict_)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 247, in _as_declarative
return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 328, in setup_mapping
return _ClassScanMapperConfig(
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 578, in __init__
self._setup_table(table)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1729, in _setup_table
table_cls(
File "", line 2, in __new__
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 436, in __new__
return cls._new(*args, **kw)
File "/opt/klevernet_venv/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 468, in _new
raise exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Table 'langchain_pg_collection' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
```
### Suggestion:
_No response_ | https://github.com/langchain-ai/langchain/issues/14699 | https://github.com/langchain-ai/langchain/pull/14726 | 1cec0afc62697ee730aa1378b69ab4556ffecffc | 9fb26a2a718bc18a5ce48f04cf6b66bc4751b734 | "2023-12-14T06:51:40Z" | python | "2023-12-14T21:27:30Z" | libs/community/langchain_community/vectorstores/pgvector.py | fetch_k=fetch_k,
lambda_mult=lambda_mult,
filter=filter,
**kwargs,
)
return _results_to_docs(docs_and_scores)
async def amax_marginal_relevance_search_by_vector(
self,
embedding: List[float],
k: int = 4,
fetch_k: int = 20,
lambda_mult: float = 0.5,
filter: Optional[Dict[str, str]] = None,
**kwargs: Any,
) -> List[Document]:
"""Return docs selected using the maximal marginal relevance."""
func = partial(
self.max_marginal_relevance_search_by_vector,
embedding,
k=k,
fetch_k=fetch_k,
lambda_mult=lambda_mult,
filter=filter,
**kwargs,
)
return await asyncio.get_event_loop().run_in_executor(None, func) |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 14,904 | Issue: cannot import name 'LLMContentHandler' from 'langchain.llms.sagemaker_endpoint | Cannot import LLMContentHandler
langchain: 0.0.351
python: 3.9
To reproduce:
``` python
from langchain.llms.sagemaker_endpoint import LLMContentHandler
```
Issue could be resolved by updating
https://github.com/langchain-ai/langchain/blob/583696732cbaa3d1cf3a3a9375539a7e8785850c/libs/langchain/langchain/llms/sagemaker_endpoint.py#L1C5-L7
as follow:
``` python
from langchain_community.llms.sagemaker_endpoint import (
LLMContentHandler,
SagemakerEndpoint,
)
__all__ = [
"SagemakerEndpoint",
"LLMContentHandler"
]
```
| https://github.com/langchain-ai/langchain/issues/14904 | https://github.com/langchain-ai/langchain/pull/14906 | 4f4b078bf3b2ea3c150f0a03765eae24efda6c1a | 1069a93d187bcaa290d087d3754ef1189882add9 | "2023-12-19T13:53:31Z" | python | "2023-12-19T15:00:32Z" | libs/langchain/langchain/llms/sagemaker_endpoint.py | from langchain_community.llms.sagemaker_endpoint import (
SagemakerEndpoint,
)
__all__ = [
"SagemakerEndpoint",
] |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | from __future__ import annotations
import importlib
from typing import (
Any,
AsyncIterator,
Dict,
Iterable,
List,
Mapping,
Sequence,
Union,
overload,
)
from langchain_core.chat_sessions import ChatSession
from langchain_core.messages import (
AIMessage,
AIMessageChunk,
BaseMessage,
BaseMessageChunk,
ChatMessage,
FunctionMessage,
HumanMessage,
SystemMessage,
ToolMessage,
)
from langchain_core.pydantic_v1 import BaseModel
from typing_extensions import Literal
async def aenumerate( |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | iterable: AsyncIterator[Any], start: int = 0
) -> AsyncIterator[tuple[int, Any]]:
"""Async version of enumerate function."""
i = start
async for x in iterable:
yield i, x
i += 1
class IndexableBaseModel(BaseModel):
"""Allows a BaseModel to return its fields by string variable indexing"""
def __getitem__(self, item: str) -> Any:
return getattr(self, item)
class Choice(IndexableBaseModel):
message: dict
class ChatCompletions(IndexableBaseModel):
choices: List[Choice]
class ChoiceChunk(IndexableBaseModel): |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | delta: dict
class ChatCompletionChunk(IndexableBaseModel):
choices: List[ChoiceChunk]
def convert_dict_to_message(_dict: Mapping[str, Any]) -> BaseMessage:
"""Convert a dictionary to a LangChain message.
Args:
_dict: The dictionary.
Returns:
The LangChain message.
"""
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
content = _dict.get("content", "") or ""
additional_kwargs: Dict = {}
if _dict.get("function_call"):
additional_kwargs["function_call"] = dict(_dict["function_call"])
if _dict.get("tool_calls"):
additional_kwargs["tool_calls"] = _dict["tool_calls"]
return AIMessage(content=content, additional_kwargs=additional_kwargs)
elif role == "system":
return SystemMessage(content=_dict["content"])
elif role == "function":
return FunctionMessage(content=_dict["content"], name=_dict["name"])
elif role == "tool":
additional_kwargs = {}
if "name" in _dict: |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | additional_kwargs["name"] = _dict["name"]
return ToolMessage(
content=_dict["content"],
tool_call_id=_dict["tool_call_id"],
additional_kwargs=additional_kwargs,
)
else:
return ChatMessage(content=_dict["content"], role=role)
def convert_message_to_dict(message: BaseMessage) -> dict:
"""Convert a LangChain message to a dictionary.
Args:
message: The LangChain message.
Returns:
The dictionary.
"""
message_dict: Dict[str, Any]
if isinstance(message, ChatMessage):
message_dict = {"role": message.role, "content": message.content}
elif isinstance(message, HumanMessage):
message_dict = {"role": "user", "content": message.content}
elif isinstance(message, AIMessage):
message_dict = {"role": "assistant", "content": message.content}
if "function_call" in message.additional_kwargs:
message_dict["function_call"] = message.additional_kwargs["function_call"]
if message_dict["content"] == "":
message_dict["content"] = None
if "tool_calls" in message.additional_kwargs:
message_dict["tool_calls"] = message.additional_kwargs["tool_calls"] |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | if message_dict["content"] == "":
message_dict["content"] = None
elif isinstance(message, SystemMessage):
message_dict = {"role": "system", "content": message.content}
elif isinstance(message, FunctionMessage):
message_dict = {
"role": "function",
"content": message.content,
"name": message.name,
}
elif isinstance(message, ToolMessage):
message_dict = {
"role": "tool",
"content": message.content,
"tool_call_id": message.tool_call_id,
}
else:
raise TypeError(f"Got unknown type {message}")
if "name" in message.additional_kwargs:
message_dict["name"] = message.additional_kwargs["name"]
return message_dict
def convert_openai_messages(messages: Sequence[Dict[str, Any]]) -> List[BaseMessage]:
"""Convert dictionaries representing OpenAI messages to LangChain format.
Args:
messages: List of dictionaries representing OpenAI messages
Returns:
List of LangChain BaseMessage objects.
"""
return [convert_dict_to_message(m) for m in messages]
def _convert_message_chunk(chunk: BaseMessageChunk, i: int) -> dict: |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | _dict: Dict[str, Any] = {}
if isinstance(chunk, AIMessageChunk):
if i == 0:
_dict["role"] = "assistant"
if "function_call" in chunk.additional_kwargs:
_dict["function_call"] = chunk.additional_kwargs["function_call"]
if i == 0:
_dict["content"] = None
else:
_dict["content"] = chunk.content
else:
raise ValueError(f"Got unexpected streaming chunk type: {type(chunk)}")
if _dict == {"content": ""}:
_dict = {}
return _dict
def _convert_message_chunk_to_delta(chunk: BaseMessageChunk, i: int) -> Dict[str, Any]:
_dict = _convert_message_chunk(chunk, i)
return {"choices": [{"delta": _dict}]}
class ChatCompletion: |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | """Chat completion."""
@overload
@staticmethod
def create(
messages: Sequence[Dict[str, Any]],
*,
provider: str = "ChatOpenAI",
stream: Literal[False] = False,
**kwargs: Any,
) -> dict:
...
@overload
@staticmethod
def create( |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | messages: Sequence[Dict[str, Any]],
*,
provider: str = "ChatOpenAI",
stream: Literal[True],
**kwargs: Any,
) -> Iterable:
...
@staticmethod
def create(
messages: Sequence[Dict[str, Any]],
*,
provider: str = "ChatOpenAI",
stream: bool = False,
**kwargs: Any,
) -> Union[dict, Iterable]:
models = importlib.import_module("langchain.chat_models")
model_cls = getattr(models, provider)
model_config = model_cls(**kwargs)
converted_messages = convert_openai_messages(messages)
if not stream:
result = model_config.invoke(converted_messages)
return {"choices": [{"message": convert_message_to_dict(result)}]}
else:
return (
_convert_message_chunk_to_delta(c, i)
for i, c in enumerate(model_config.stream(converted_messages))
)
@overload
@staticmethod
async def acreate( |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | messages: Sequence[Dict[str, Any]],
*,
provider: str = "ChatOpenAI",
stream: Literal[False] = False,
**kwargs: Any,
) -> dict:
...
@overload
@staticmethod
async def acreate( |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | messages: Sequence[Dict[str, Any]],
*,
provider: str = "ChatOpenAI",
stream: Literal[True],
**kwargs: Any,
) -> AsyncIterator:
...
@staticmethod
async def acreate(
messages: Sequence[Dict[str, Any]],
*,
provider: str = "ChatOpenAI",
stream: bool = False,
**kwargs: Any,
) -> Union[dict, AsyncIterator]:
models = importlib.import_module("langchain.chat_models")
model_cls = getattr(models, provider)
model_config = model_cls(**kwargs)
converted_messages = convert_openai_messages(messages)
if not stream:
result = await model_config.ainvoke(converted_messages)
return {"choices": [{"message": convert_message_to_dict(result)}]}
else:
return (
_convert_message_chunk_to_delta(c, i)
async for i, c in aenumerate(model_config.astream(converted_messages))
)
def _has_assistant_message(session: ChatSession) -> bool: |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | """Check if chat session has an assistant message."""
return any([isinstance(m, AIMessage) for m in session["messages"]])
def convert_messages_for_finetuning(
sessions: Iterable[ChatSession],
) -> List[List[dict]]:
"""Convert messages to a list of lists of dictionaries for fine-tuning.
Args:
sessions: The chat sessions.
Returns:
The list of lists of dictionaries.
"""
return [
[convert_message_to_dict(s) for s in session["messages"]]
for session in sessions
if _has_assistant_message(session)
]
class Completions: |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | """Completion."""
@overload
@staticmethod
def create(
messages: Sequence[Dict[str, Any]],
*,
provider: str = "ChatOpenAI",
stream: Literal[False] = False,
**kwargs: Any,
) -> ChatCompletions:
...
@overload
@staticmethod
def create(
messages: Sequence[Dict[str, Any]],
*,
provider: str = "ChatOpenAI",
stream: Literal[True],
**kwargs: Any,
) -> Iterable:
...
@staticmethod
def create( |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | messages: Sequence[Dict[str, Any]],
*,
provider: str = "ChatOpenAI",
stream: bool = False,
**kwargs: Any,
) -> Union[ChatCompletions, Iterable]:
models = importlib.import_module("langchain.chat_models")
model_cls = getattr(models, provider)
model_config = model_cls(**kwargs)
converted_messages = convert_openai_messages(messages)
if not stream:
result = model_config.invoke(converted_messages)
return ChatCompletions(
choices=[Choice(message=convert_message_to_dict(result))]
)
else:
return (
ChatCompletionChunk(
choices=[ChoiceChunk(delta=_convert_message_chunk(c, i))]
)
for i, c in enumerate(model_config.stream(converted_messages))
)
@overload
@staticmethod
async def acreate( |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | messages: Sequence[Dict[str, Any]],
*,
provider: str = "ChatOpenAI",
stream: Literal[False] = False,
**kwargs: Any,
) -> ChatCompletions:
...
@overload
@staticmethod
async def acreate(
messages: Sequence[Dict[str, Any]],
*,
provider: str = "ChatOpenAI",
stream: Literal[True],
**kwargs: Any,
) -> AsyncIterator:
...
@staticmethod
async def acreate( |
closed | langchain-ai/langchain | https://github.com/langchain-ai/langchain | 5,861 | KeyError 'content' | ### System Info
Langchain version 165
Python 3.9
### Who can help?
_No response_
### Information
- [ ] The official example notebooks/scripts
- [ ] My own modified scripts
### Related Components
- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
### Reproduction
I call llm with llm.generate(xxx) on my code.
We are connected to the Azure OpenAI Service, and strangely enough, in a production environment, the following error is occasionally returned:
`File \"/usr/local/lib/python3.9/site-packages/langchain/chat_models/openai.py\", line 75, in _convert_dict_to_message return AIMessage( content=_dict[\"content\"]) KeyError: 'content'`
Checked the Langchain source code, it is in this piece of code can not find the 'content' element, take the message locally and retry, the message body is normal:
``` python
def _convert_dict_to_message(_dict: dict) -> BaseMessage:
role = _dict["role"]
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
return AIMessage(content=_dict["content"])
elif role == "system":
return SystemMessage(content=_dict["content"])
else:
return ChatMessage(content=_dict["content"], role=role)
```
Suggestions for fixing:
1、When there is an error, can the error log be more detailed?
2、whether to provide a method to return only the response, the caller to deal with their own?
### Expected behavior
should have no error | https://github.com/langchain-ai/langchain/issues/5861 | https://github.com/langchain-ai/langchain/pull/14765 | b0588774f142e00d24c6852077a57b56e3888022 | 5642132c0c615ecd0984d5e9c45ef6076ccc69d2 | "2023-06-08T03:09:03Z" | python | "2023-12-20T06:17:23Z" | libs/community/langchain_community/adapters/openai.py | messages: Sequence[Dict[str, Any]],
*,
provider: str = "ChatOpenAI",
stream: bool = False,
**kwargs: Any,
) -> Union[ChatCompletions, AsyncIterator]:
models = importlib.import_module("langchain.chat_models")
model_cls = getattr(models, provider)
model_config = model_cls(**kwargs)
converted_messages = convert_openai_messages(messages)
if not stream:
result = await model_config.ainvoke(converted_messages)
return ChatCompletions(
choices=[Choice(message=convert_message_to_dict(result))]
)
else:
return (
ChatCompletionChunk(
choices=[ChoiceChunk(delta=_convert_message_chunk(c, i))]
)
async for i, c in aenumerate(model_config.astream(converted_messages))
)
class Chat:
def __init__(self) -> None:
self.completions = Completions()
chat = Chat() |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 516 | The task instance of MR cannot stop in some cases | The task instance of MR cannot stop in some cases | https://github.com/apache/dolphinscheduler/issues/516 | https://github.com/apache/dolphinscheduler/pull/560 | f880a76d7a3a95d4b425a16853456025292b8c03 | d3e59773085cf287e908a789b58a14285a57da43 | "2019-07-04T04:51:57Z" | java | "2019-07-10T09:21:12Z" | escheduler-server/src/main/java/cn/escheduler/server/utils/LoggerUtils.java | /*
* 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 cn.escheduler.server.utils;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* logger utils
*/
public class LoggerUtils { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 516 | The task instance of MR cannot stop in some cases | The task instance of MR cannot stop in some cases | https://github.com/apache/dolphinscheduler/issues/516 | https://github.com/apache/dolphinscheduler/pull/560 | f880a76d7a3a95d4b425a16853456025292b8c03 | d3e59773085cf287e908a789b58a14285a57da43 | "2019-07-04T04:51:57Z" | java | "2019-07-10T09:21:12Z" | escheduler-server/src/main/java/cn/escheduler/server/utils/LoggerUtils.java | /**
* rules for extracting application ID
*/
private static final Pattern APPLICATION_REGEX = Pattern.compile("\\d+_\\d+");
/**
* build job id
* @param affix
* @param processDefId
* @param processInstId
* @param taskId
* @return
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 516 | The task instance of MR cannot stop in some cases | The task instance of MR cannot stop in some cases | https://github.com/apache/dolphinscheduler/issues/516 | https://github.com/apache/dolphinscheduler/pull/560 | f880a76d7a3a95d4b425a16853456025292b8c03 | d3e59773085cf287e908a789b58a14285a57da43 | "2019-07-04T04:51:57Z" | java | "2019-07-10T09:21:12Z" | escheduler-server/src/main/java/cn/escheduler/server/utils/LoggerUtils.java | public static String buildTaskId(String affix,
int processDefId,
int processInstId,
int taskId){
return String.format("%s_%s_%s_%s",affix,
processDefId,
processInstId,
taskId);
}
/**
* processing log
* get yarn application id list
* @param log
* @param logger
* @return
*/
public static List<String> getAppIds(String log, Logger logger) {
List<String> appIds = new ArrayList<String>();
Matcher matcher = APPLICATION_REGEX.matcher(log);
while (matcher.find()) {
String appId = matcher.group();
if(!appIds.contains(appId)){
logger.info("find app id: {}", appId);
appIds.add(appId);
}
}
return appIds;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | /*
* 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.dolphinscheduler.api.controller;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.ResourcesService;
import org.apache.dolphinscheduler.api.service.UdfFuncService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ResourceType;
import org.apache.dolphinscheduler.common.enums.UdfType;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.User;
import io.swagger.annotations.Api; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Map;
import static org.apache.dolphinscheduler.api.enums.Status.*;
/**
* resources controller
*/
@Api(tags = "RESOURCES_TAG", position = 1)
@RestController
@RequestMapping("resources")
public class ResourcesController extends BaseController{
private static final Logger logger = LoggerFactory.getLogger(ResourcesController.class);
@Autowired
private ResourcesService resourceService;
@Autowired
private UdfFuncService udfFuncService;
/**
* create resource |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | *
* @param loginUser login user
* @param alias alias
* @param description description
* @param type type
* @param file file
* @return create result code
*/
@ApiOperation(value = "createResource", notes= "CREATE_RESOURCE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = true, dataType ="ResourceType"),
@ApiImplicitParam(name = "name", value = "RESOURCE_NAME", required = true, dataType ="String"),
@ApiImplicitParam(name = "description", value = "RESOURCE_DESC", dataType ="String"),
@ApiImplicitParam(name = "file", value = "RESOURCE_FILE", required = true, dataType = "MultipartFile")
})
@PostMapping(value = "/create")
public Result createResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "type") ResourceType type,
@RequestParam(value ="name")String alias,
@RequestParam(value = "description", required = false) String description,
@RequestParam("file") MultipartFile file) {
try {
logger.info("login user {}, create resource, type: {}, resource alias: {}, desc: {}, file: {},{}",
loginUser.getUserName(),type, alias, description, file.getName(), file.getOriginalFilename());
return resourceService.createResource(loginUser,alias, description,type ,file);
} catch (Exception e) {
logger.error(CREATE_RESOURCE_ERROR.getMsg(),e);
return error(CREATE_RESOURCE_ERROR.getCode(), CREATE_RESOURCE_ERROR.getMsg());
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | /**
* update resource
*
* @param loginUser login user
* @param alias alias
* @param resourceId resource id
* @param type resource type
* @param description description
* @return update result code
*/
@ApiOperation(value = "updateResource", notes= "UPDATE_RESOURCE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100"),
@ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = true, dataType ="ResourceType"),
@ApiImplicitParam(name = "name", value = "RESOURCE_NAME", required = true, dataType ="String"),
@ApiImplicitParam(name = "description", value = "RESOURCE_DESC", dataType ="String"),
@ApiImplicitParam(name = "file", value = "RESOURCE_FILE", required = true,dataType = "MultipartFile")
})
@PostMapping(value = "/update")
public Result updateResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value ="id") int resourceId,
@RequestParam(value = "type") ResourceType type,
@RequestParam(value ="name")String alias,
@RequestParam(value = "description", required = false) String description) {
try {
logger.info("login user {}, update resource, type: {}, resource alias: {}, desc: {}",
loginUser.getUserName(),type, alias, description);
return resourceService.updateResource(loginUser,resourceId,alias, description,type);
} catch (Exception e) {
logger.error(UPDATE_RESOURCE_ERROR.getMsg(),e); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | return error(Status.UPDATE_RESOURCE_ERROR.getCode(), Status.UPDATE_RESOURCE_ERROR.getMsg());
}
}
/**
* query resources list
*
* @param loginUser login user
* @param type resource type
* @return resource list
*/
@ApiOperation(value = "queryResourceList", notes= "QUERY_RESOURCE_LIST_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = true, dataType ="ResourceType")
})
@GetMapping(value="/list")
@ResponseStatus(HttpStatus.OK)
public Result queryResourceList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value ="type") ResourceType type
){
try{
logger.info("query resource list, login user:{}, resource type:{}", loginUser.getUserName(), type.toString());
Map<String, Object> result = resourceService.queryResourceList(loginUser, type);
return returnDataList(result);
}catch (Exception e){
logger.error(QUERY_RESOURCES_LIST_ERROR.getMsg(),e);
return error(Status.QUERY_RESOURCES_LIST_ERROR.getCode(), Status.QUERY_RESOURCES_LIST_ERROR.getMsg());
}
}
/**
* query resources list paging |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | *
* @param loginUser login user
* @param type resource type
* @param searchVal search value
* @param pageNo page number
* @param pageSize page size
* @return resource list page
*/
@ApiOperation(value = "queryResourceListPaging", notes= "QUERY_RESOURCE_LIST_PAGING_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = true, dataType ="ResourceType"),
@ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", dataType ="String"),
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType ="Int",example = "20")
})
@GetMapping(value="/list-paging")
@ResponseStatus(HttpStatus.OK)
public Result queryResourceListPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value ="type") ResourceType type,
@RequestParam("pageNo") Integer pageNo,
@RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam("pageSize") Integer pageSize
){
try{
logger.info("query resource list, login user:{}, resource type:{}, search value:{}",
loginUser.getUserName(), type.toString(), searchVal);
Map<String, Object> result = checkPageParams(pageNo, pageSize);
if(result.get(Constants.STATUS) != Status.SUCCESS){
return returnDataListPaging(result);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | searchVal = ParameterUtils.handleEscapes(searchVal);
result = resourceService.queryResourceListPaging(loginUser,type,searchVal,pageNo, pageSize);
return returnDataListPaging(result);
}catch (Exception e){
logger.error(QUERY_RESOURCES_LIST_PAGING.getMsg(),e);
return error(Status.QUERY_RESOURCES_LIST_PAGING.getCode(), Status.QUERY_RESOURCES_LIST_PAGING.getMsg());
}
}
/**
* delete resource
*
* @param loginUser login user
* @param resourceId resource id
* @return delete result code
*/
@ApiOperation(value = "deleteResource", notes= "DELETE_RESOURCE_BY_ID_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100")
})
@GetMapping(value = "/delete")
@ResponseStatus(HttpStatus.OK)
public Result deleteResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value ="id") int resourceId
) {
try{
logger.info("login user {}, delete resource id: {}",
loginUser.getUserName(),resourceId);
return resourceService.delete(loginUser,resourceId);
}catch (Exception e){
logger.error(DELETE_RESOURCE_ERROR.getMsg(),e); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | return error(Status.DELETE_RESOURCE_ERROR.getCode(), Status.DELETE_RESOURCE_ERROR.getMsg());
}
}
/**
* verify resource by alias and type
*
* @param loginUser login user
* @param alias resource name
* @param type resource type
* @return true if the resource name not exists, otherwise return false
*/
@ApiOperation(value = "verifyResourceName", notes= "VERIFY_RESOURCE_NAME_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = true, dataType ="ResourceType"),
@ApiImplicitParam(name = "name", value = "RESOURCE_NAME", required = true, dataType ="String")
})
@GetMapping(value = "/verify-name")
@ResponseStatus(HttpStatus.OK)
public Result verifyResourceName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value ="name") String alias,
@RequestParam(value ="type") ResourceType type
) {
try {
logger.info("login user {}, verfiy resource alias: {},resource type: {}",
loginUser.getUserName(), alias,type);
return resourceService.verifyResourceName(alias,type,loginUser);
} catch (Exception e) {
logger.error(VERIFY_RESOURCE_BY_NAME_AND_TYPE_ERROR.getMsg(), e);
return error(Status.VERIFY_RESOURCE_BY_NAME_AND_TYPE_ERROR.getCode(), Status.VERIFY_RESOURCE_BY_NAME_AND_TYPE_ERROR.getMsg());
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | }
/**
* view resource file online
*
* @param loginUser login user
* @param resourceId resource id
* @param skipLineNum skip line number
* @param limit limit
* @return resource content
*/
@ApiOperation(value = "viewResource", notes= "VIEW_RESOURCE_BY_ID_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100"),
@ApiImplicitParam(name = "skipLineNum", value = "SKIP_LINE_NUM", required = true, dataType ="Int", example = "100"),
@ApiImplicitParam(name = "limit", value = "LIMIT", required = true, dataType ="Int", example = "100")
})
@GetMapping(value = "/view")
public Result viewResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "id") int resourceId,
@RequestParam(value = "skipLineNum") int skipLineNum,
@RequestParam(value = "limit") int limit
) {
try{
logger.info("login user {}, view resource : {}, skipLineNum {} , limit {}",
loginUser.getUserName(),resourceId,skipLineNum,limit);
return resourceService.readResource(resourceId,skipLineNum,limit);
}catch (Exception e){
logger.error(VIEW_RESOURCE_FILE_ON_LINE_ERROR.getMsg(),e);
return error(Status.VIEW_RESOURCE_FILE_ON_LINE_ERROR.getCode(), Status.VIEW_RESOURCE_FILE_ON_LINE_ERROR.getMsg());
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | }
/**
* create resource file online
*
* @param loginUser login user
* @param type resource type
* @param fileName file name
* @param fileSuffix file suffix
* @param description description
* @param content content
* @return create result code
*/
@ApiOperation(value = "onlineCreateResource", notes= "ONLINE_CREATE_RESOURCE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = true, dataType ="ResourceType"),
@ApiImplicitParam(name = "fileName", value = "RESOURCE_NAME",required = true, dataType ="String"),
@ApiImplicitParam(name = "suffix", value = "SUFFIX", required = true, dataType ="String"),
@ApiImplicitParam(name = "description", value = "RESOURCE_DESC", dataType ="String"),
@ApiImplicitParam(name = "content", value = "CONTENT",required = true, dataType ="String")
})
@PostMapping(value = "/online-create")
public Result onlineCreateResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "type") ResourceType type,
@RequestParam(value ="fileName")String fileName,
@RequestParam(value ="suffix")String fileSuffix,
@RequestParam(value = "description", required = false) String description,
@RequestParam(value = "content") String content
) {
try{
logger.info("login user {}, online create resource! fileName : {}, type : {}, suffix : {},desc : {},content : {}", |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | loginUser.getUserName(),type,fileName,fileSuffix,description,content);
if(StringUtils.isEmpty(content)){
logger.error("resource file contents are not allowed to be empty");
return error(Status.RESOURCE_FILE_IS_EMPTY.getCode(), RESOURCE_FILE_IS_EMPTY.getMsg());
}
return resourceService.onlineCreateResource(loginUser,type,fileName,fileSuffix,description,content);
}catch (Exception e){
logger.error(CREATE_RESOURCE_FILE_ON_LINE_ERROR.getMsg(),e);
return error(Status.CREATE_RESOURCE_FILE_ON_LINE_ERROR.getCode(), Status.CREATE_RESOURCE_FILE_ON_LINE_ERROR.getMsg());
}
}
/**
* edit resource file online
*
* @param loginUser login user
* @param resourceId resource id
* @param content content
* @return update result code
*/
@ApiOperation(value = "updateResourceContent", notes= "UPDATE_RESOURCE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100"),
@ApiImplicitParam(name = "content", value = "CONTENT",required = true, dataType ="String")
})
@PostMapping(value = "/update-content")
public Result updateResourceContent(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "id") int resourceId,
@RequestParam(value = "content") String content
) {
try{ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | logger.info("login user {}, updateProcessInstance resource : {}",
loginUser.getUserName(),resourceId);
if(StringUtils.isEmpty(content)){
logger.error("The resource file contents are not allowed to be empty");
return error(Status.RESOURCE_FILE_IS_EMPTY.getCode(), RESOURCE_FILE_IS_EMPTY.getMsg());
}
return resourceService.updateResourceContent(resourceId,content);
}catch (Exception e){
logger.error(EDIT_RESOURCE_FILE_ON_LINE_ERROR.getMsg(),e);
return error(Status.EDIT_RESOURCE_FILE_ON_LINE_ERROR.getCode(), Status.EDIT_RESOURCE_FILE_ON_LINE_ERROR.getMsg());
}
}
/**
* download resource file
*
* @param loginUser login user
* @param resourceId resource id
* @return resource content
*/
@ApiOperation(value = "downloadResource", notes= "DOWNLOAD_RESOURCE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100")
})
@GetMapping(value = "/download")
@ResponseBody
public ResponseEntity downloadResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "id") int resourceId) {
try{
logger.info("login user {}, download resource : {}",
loginUser.getUserName(), resourceId); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | Resource file = resourceService.downloadResource(resourceId);
if (file == null) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(Status.RESOURCE_NOT_EXIST.getMsg());
}
return ResponseEntity
.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getFilename() + "\"")
.body(file);
}catch (Exception e){
logger.error(DOWNLOAD_RESOURCE_FILE_ERROR.getMsg(),e);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(Status.DOWNLOAD_RESOURCE_FILE_ERROR.getMsg());
}
}
/**
* create udf function
* @param loginUser login user
* @param type udf type
* @param funcName function name
* @param argTypes argument types
* @param database database
* @param description description
* @param className class name
* @param resourceId resource id
* @return create result code
*/
@ApiOperation(value = "createUdfFunc", notes= "CREATE_UDF_FUNCTION_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "UDF_TYPE", required = true, dataType ="UdfType"),
@ApiImplicitParam(name = "funcName", value = "FUNC_NAME",required = true, dataType ="String"),
@ApiImplicitParam(name = "suffix", value = "CLASS_NAME", required = true, dataType ="String"), |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | @ApiImplicitParam(name = "argTypes", value = "ARG_TYPES", dataType ="String"),
@ApiImplicitParam(name = "database", value = "DATABASE_NAME", dataType ="String"),
@ApiImplicitParam(name = "description", value = "UDF_DESC", dataType ="String"),
@ApiImplicitParam(name = "resourceId", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100")
})
@PostMapping(value = "/udf-func/create")
@ResponseStatus(HttpStatus.CREATED)
public Result createUdfFunc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "type") UdfType type,
@RequestParam(value ="funcName")String funcName,
@RequestParam(value ="className")String className,
@RequestParam(value ="argTypes", required = false)String argTypes,
@RequestParam(value ="database", required = false)String database,
@RequestParam(value = "description", required = false) String description,
@RequestParam(value = "resourceId") int resourceId) {
logger.info("login user {}, create udf function, type: {}, funcName: {},argTypes: {} ,database: {},desc: {},resourceId: {}",
loginUser.getUserName(),type, funcName, argTypes,database,description, resourceId);
Result result = new Result();
try {
return udfFuncService.createUdfFunction(loginUser,funcName,className,argTypes,database,description,type,resourceId);
} catch (Exception e) {
logger.error(CREATE_UDF_FUNCTION_ERROR.getMsg(),e);
return error(Status.CREATE_UDF_FUNCTION_ERROR.getCode(), Status.CREATE_UDF_FUNCTION_ERROR.getMsg());
}
}
/**
* view udf function
*
* @param loginUser login user
* @param id resource id |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | * @return udf function detail
*/
@ApiOperation(value = "viewUIUdfFunction", notes= "VIEW_UDF_FUNCTION_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "resourceId", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100")
})
@GetMapping(value = "/udf-func/update-ui")
@ResponseStatus(HttpStatus.OK)
public Result viewUIUdfFunction(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("id") int id) {
logger.info("login user {}, query udf{}",
loginUser.getUserName(), id);
try {
Map<String, Object> map = udfFuncService.queryUdfFuncDetail(id);
return returnDataList(map);
} catch (Exception e) {
logger.error(VIEW_UDF_FUNCTION_ERROR.getMsg(),e);
return error(Status.VIEW_UDF_FUNCTION_ERROR.getCode(), Status.VIEW_UDF_FUNCTION_ERROR.getMsg());
}
}
/**
* update udf function
*
* @param loginUser login user
* @param type resource type
* @param funcName function name
* @param argTypes argument types
* @param database data base
* @param description description
* @param resourceId resource id |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | * @param className class name
* @param udfFuncId udf function id
* @return update result code
*/
@ApiOperation(value = "updateUdfFunc", notes= "UPDATE_UDF_FUNCTION_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "UDF_TYPE", required = true, dataType ="UdfType"),
@ApiImplicitParam(name = "funcName", value = "FUNC_NAME",required = true, dataType ="String"),
@ApiImplicitParam(name = "suffix", value = "CLASS_NAME", required = true, dataType ="String"),
@ApiImplicitParam(name = "argTypes", value = "ARG_TYPES", dataType ="String"),
@ApiImplicitParam(name = "database", value = "DATABASE_NAME", dataType ="String"),
@ApiImplicitParam(name = "description", value = "UDF_DESC", dataType ="String"),
@ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100")
})
@PostMapping(value = "/udf-func/update")
public Result updateUdfFunc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "id") int udfFuncId,
@RequestParam(value = "type") UdfType type,
@RequestParam(value ="funcName")String funcName,
@RequestParam(value ="className")String className,
@RequestParam(value ="argTypes", required = false)String argTypes,
@RequestParam(value ="database", required = false)String database,
@RequestParam(value = "description", required = false) String description,
@RequestParam(value = "resourceId") int resourceId) {
try {
logger.info("login user {}, updateProcessInstance udf function id: {},type: {}, funcName: {},argTypes: {} ,database: {},desc: {},resourceId: {}",
loginUser.getUserName(),udfFuncId,type, funcName, argTypes,database,description, resourceId);
Map<String, Object> result = udfFuncService.updateUdfFunc(udfFuncId,funcName,className,argTypes,database,description,type,resourceId);
return returnDataList(result);
} catch (Exception e) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | logger.error(UPDATE_UDF_FUNCTION_ERROR.getMsg(),e);
return error(Status.UPDATE_UDF_FUNCTION_ERROR.getCode(), Status.UPDATE_UDF_FUNCTION_ERROR.getMsg());
}
}
/**
* query udf function list paging
*
* @param loginUser login user
* @param searchVal search value
* @param pageNo page number
* @param pageSize page size
* @return udf function list page
*/
@ApiOperation(value = "queryUdfFuncListPaging", notes= "QUERY_UDF_FUNCTION_LIST_PAGING_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", dataType ="String"),
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType ="Int",example = "20")
})
@GetMapping(value="/udf-func/list-paging")
@ResponseStatus(HttpStatus.OK)
public Result queryUdfFuncList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("pageNo") Integer pageNo,
@RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam("pageSize") Integer pageSize
){
try{
logger.info("query udf functions list, login user:{},search value:{}",
loginUser.getUserName(), searchVal);
Map<String, Object> result = checkPageParams(pageNo, pageSize); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | if(result.get(Constants.STATUS) != Status.SUCCESS){
return returnDataListPaging(result);
}
result = udfFuncService.queryUdfFuncListPaging(loginUser,searchVal,pageNo, pageSize);
return returnDataListPaging(result);
}catch (Exception e){
logger.error(QUERY_UDF_FUNCTION_LIST_PAGING_ERROR.getMsg(),e);
return error(Status.QUERY_UDF_FUNCTION_LIST_PAGING_ERROR.getCode(), Status.QUERY_UDF_FUNCTION_LIST_PAGING_ERROR.getMsg());
}
}
/**
* query resource list by type
*
* @param loginUser login user
* @param type resource type
* @return resource list
*/
@ApiOperation(value = "queryResourceList", notes= "QUERY_RESOURCE_LIST_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "UDF_TYPE", required = true, dataType ="UdfType")
})
@GetMapping(value="/udf-func/list")
@ResponseStatus(HttpStatus.OK)
public Result queryResourceList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("type") UdfType type){
try{
logger.info("query datasource list, user:{}, type:{}", loginUser.getUserName(), type.toString());
Map<String, Object> result = udfFuncService.queryResourceList(loginUser,type.ordinal());
return returnDataList(result);
}catch (Exception e){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | logger.error(QUERY_DATASOURCE_BY_TYPE_ERROR.getMsg(),e);
return error(Status.QUERY_DATASOURCE_BY_TYPE_ERROR.getCode(),QUERY_DATASOURCE_BY_TYPE_ERROR.getMsg());
}
}
/**
* verify udf function name can use or not
*
* @param loginUser login user
* @param name name
* @return true if the name can user, otherwise return false
*/
@ApiOperation(value = "verifyUdfFuncName", notes= "VERIFY_UDF_FUNCTION_NAME_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "FUNC_NAME",required = true, dataType ="String")
})
@GetMapping(value = "/udf-func/verify-name")
@ResponseStatus(HttpStatus.OK)
public Result verifyUdfFuncName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value ="name") String name
) {
logger.info("login user {}, verfiy udf function name: {}",
loginUser.getUserName(),name);
try{
return udfFuncService.verifyUdfFuncByName(name);
}catch (Exception e){
logger.error(VERIFY_UDF_FUNCTION_NAME_ERROR.getMsg(),e);
return error(Status.VERIFY_UDF_FUNCTION_NAME_ERROR.getCode(), Status.VERIFY_UDF_FUNCTION_NAME_ERROR.getMsg());
}
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | * delete udf function
*
* @param loginUser login user
* @param udfFuncId udf function id
* @return delete result code
*/
@ApiOperation(value = "deleteUdfFunc", notes= "DELETE_UDF_FUNCTION_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100")
})
@GetMapping(value = "/udf-func/delete")
@ResponseStatus(HttpStatus.OK)
public Result deleteUdfFunc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value ="id") int udfFuncId
) {
try{
logger.info("login user {}, delete udf function id: {}", loginUser.getUserName(),udfFuncId);
return udfFuncService.delete(udfFuncId);
}catch (Exception e){
logger.error(DELETE_UDF_FUNCTION_ERROR.getMsg(),e);
return error(Status.DELETE_UDF_FUNCTION_ERROR.getCode(), Status.DELETE_UDF_FUNCTION_ERROR.getMsg());
}
}
/**
* authorized file resource list
*
* @param loginUser login user
* @param userId user id
* @return authorized result
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | @ApiOperation(value = "authorizedFile", notes= "AUTHORIZED_FILE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType ="Int", example = "100")
})
@GetMapping(value = "/authed-file")
@ResponseStatus(HttpStatus.CREATED)
public Result authorizedFile(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("userId") Integer userId) {
try{
logger.info("authorized file resource, user: {}, user id:{}", loginUser.getUserName(), userId);
Map<String, Object> result = resourceService.authorizedFile(loginUser, userId);
return returnDataList(result);
}catch (Exception e){
logger.error(AUTHORIZED_FILE_RESOURCE_ERROR.getMsg(),e);
return error(Status.AUTHORIZED_FILE_RESOURCE_ERROR.getCode(), Status.AUTHORIZED_FILE_RESOURCE_ERROR.getMsg());
}
}
/**
* unauthorized file resource list
*
* @param loginUser login user
* @param userId user id
* @return unauthorized result code
*/
@ApiOperation(value = "unauthorizedFile", notes= "UNAUTHORIZED_FILE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType ="Int", example = "100")
})
@GetMapping(value = "/unauth-file")
@ResponseStatus(HttpStatus.CREATED) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | public Result unauthorizedFile(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("userId") Integer userId) {
try{
logger.info("resource unauthorized file, user:{}, unauthorized user id:{}", loginUser.getUserName(), userId);
Map<String, Object> result = resourceService.unauthorizedFile(loginUser, userId);
return returnDataList(result);
}catch (Exception e){
logger.error(UNAUTHORIZED_FILE_RESOURCE_ERROR.getMsg(),e);
return error(Status.UNAUTHORIZED_FILE_RESOURCE_ERROR.getCode(), Status.UNAUTHORIZED_FILE_RESOURCE_ERROR.getMsg());
}
}
/**
* unauthorized udf function
*
* @param loginUser login user
* @param userId user id
* @return unauthorized result code
*/
@ApiOperation(value = "unauthUDFFunc", notes= "UNAUTHORIZED_UDF_FUNC_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType ="Int", example = "100")
})
@GetMapping(value = "/unauth-udf-func")
@ResponseStatus(HttpStatus.CREATED)
public Result unauthUDFFunc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("userId") Integer userId) {
try{
logger.info("unauthorized udf function, login user:{}, unauthorized user id:{}", loginUser.getUserName(), userId);
Map<String, Object> result = resourceService.unauthorizedUDFFunction(loginUser, userId);
return returnDataList(result); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,399 | [BUG] The wrong field order in logger.info | **Describe the bug**
The method onlineCreateResource in class ResourcesController,The logger.info has wrong field order with fileName and type.
**Screenshots**
<img width="1021" alt="" src="https://user-images.githubusercontent.com/3699743/70215243-0f64cc80-1778-11ea-9ec5-f6a38559b051.png">
**Which version of Dolphin Scheduler:**
- [dev-db branch]
| https://github.com/apache/dolphinscheduler/issues/1399 | https://github.com/apache/dolphinscheduler/pull/1400 | b3a0e1fd148c876d61bce92fea14528c3fb2cf45 | f134453bb838c76f046fc450ef15afccd857074e | "2019-12-05T07:59:57Z" | java | "2019-12-05T09:04:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | }catch (Exception e){
logger.error(UNAUTHORIZED_UDF_FUNCTION_ERROR.getMsg(),e);
return error(Status.UNAUTHORIZED_UDF_FUNCTION_ERROR.getCode(), Status.UNAUTHORIZED_UDF_FUNCTION_ERROR.getMsg());
}
}
/**
* authorized udf function
*
* @param loginUser login user
* @param userId user id
* @return authorized result code
*/
@ApiOperation(value = "authUDFFunc", notes= "AUTHORIZED_UDF_FUNC_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType ="Int", example = "100")
})
@GetMapping(value = "/authed-udf-func")
@ResponseStatus(HttpStatus.CREATED)
public Result authorizedUDFFunction(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("userId") Integer userId) {
try{
logger.info("auth udf function, login user:{}, auth user id:{}", loginUser.getUserName(), userId);
Map<String, Object> result = resourceService.authorizedUDFFunction(loginUser, userId);
return returnDataList(result);
}catch (Exception e){
logger.error(AUTHORIZED_UDF_FUNCTION_ERROR.getMsg(),e);
return error(Status.AUTHORIZED_UDF_FUNCTION_ERROR.getCode(), Status.AUTHORIZED_UDF_FUNCTION_ERROR.getMsg());
}
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | /*
* 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.dolphinscheduler.common;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
import org.apache.dolphinscheduler.common.utils.OSUtils;
import java.util.regex.Pattern;
/**
* Constants
*/
public final class Constants { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | /**
* zookeeper properties path
*/
public static final String ZOOKEEPER_PROPERTIES_PATH = "zookeeper.properties";
/**
* hadoop properties path
*/
public static final String HADOOP_PROPERTIES_PATH = "/common/hadoop/hadoop.properties";
/**
* common properties path
*/
public static final String COMMON_PROPERTIES_PATH = "/common/common.properties";
/**
* dao properties path
*/
public statO_PROPERTIES_PATH = "application.properties";
/**
* fs.defaultFS
*/
public static final String FS_DEFAULTFS = "fs.defaultFS";
/**
* fs s3a endpoint
*/
public static final String FS_S3A_ENDPOINT = "fs.s3a.endpoint";
/**
* fs s3a access key |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | */
public static final String FS_S3A_ACCESS_KEY = "fs.s3a.access.key";
/**
* fs s3a secret key
*/
public static final String FS_S3A_SECRET_KEY = "fs.s3a.secret.key";
/**
* yarn.resourcemanager.ha.rm.idsfs.defaultFS
*/
public static final String YARN_RESOURCEMANAGER_HA_RM_IDS = "yarn.resourcemanager.ha.rm.ids";
/**
* yarn.application.status.address
*/
public static final String YARN_APPLICATION_STATUS_ADDRESS = "yarn.application.status.address";
/**
* hdfs configuration
* hdfs.root.user
*/
public static final String HDFS_ROOT_USER = "hdfs.root.user";
/**
* hdfs configuration
* data.store2hdfs.basepath
*/
public statTA_STORE_2_HDFS_BASEPATH = "data.store2hdfs.basepath";
/**
* data.basedir.path
*/
public statTA_BASEDIR_PATH = "data.basedir.path";
/**
* data.download.basedir.path |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | */
public statTA_DOWNLOAD_BASEDIR_PATH = "data.download.basedir.path";
/**
* process.exec.basepath
*/
public static final String PROCESS_EXEC_BASEPATH = "process.exec.basepath";
/**
* dolphinscheduler.env.path
*/
public static final String DOLPHINSCHEDULER_ENV_PATH = "dolphinscheduler.env.path";
/**
* python home
*/
public static final String PYTHON_HOME="PYTHON_HOME";
/**
* resource.view.suffixs
*/
publSOURCE_VIEW_SUFFIXS = "resource.view.suffixs";
/**
* development.state
*/
public static final String DEVELOPMENT_STATE = "development.state";
/**
* res.upload.startup.type
*/
publS_UPLOAD_STARTUP_TYPE = "res.upload.startup.type";
/**
* zookeeper quorum
*/
public static final String ZOOKEEPER_QUORUM = "zookeeper.quorum"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | /**
* MasterServer directory registered in zookeeper
*/
public static final String ZOOKEEPER_DOLPHINSCHEDULER_MASTERS = "zookeeper.dolphinscheduler.masters";
/**
* WorkerServer directory registered in zookeeper
*/
public static final String ZOOKEEPER_DOLPHINSCHEDULER_WORKERS = "zookeeper.dolphinscheduler.workers";
/**
* all servers directory registered in zookeeper
*/
public static final String ZOOKEEPER_DOLPHINSCHEDULER_DEAD_SERVERS = "zookeeper.dolphinscheduler.dead.servers";
/**
* MasterServer lock directory registered in zookeeper
*/
public static final String ZOOKEEPER_DOLPHINSCHEDULER_LOCK_MASTERS = "zookeeper.dolphinscheduler.lock.masters";
/**
* WorkerServer lock directory registered in zookeeper
*/
public static final String ZOOKEEPER_DOLPHINSCHEDULER_LOCK_WORKERS = "zookeeper.dolphinscheduler.lock.workers";
/**
* MasterServer failover directory registered in zookeeper
*/
public static final String ZOOKEEPER_DOLPHINSCHEDULER_LOCK_FAILOVER_MASTERS = "zookeeper.dolphinscheduler.lock.failover.masters";
/**
* WorkerServer failover directory registered in zookeeper
*/
public static final String ZOOKEEPER_DOLPHINSCHEDULER_LOCK_FAILOVER_WORKERS = "zookeeper.dolphinscheduler.lock.failover.workers";
/**
* MasterServer startup failover runing and fault tolerance process |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | */
public static final String ZOOKEEPER_DOLPHINSCHEDULER_LOCK_FAILOVER_STARTUP_MASTERS = "zookeeper.dolphinscheduler.lock.failover.startup.masters";
/**
* need send warn times when master server or worker server failover
*/
public static final int DOLPHINSCHEDULER_WARN_TIMES_FAILOVER = 3;
/**
* comma ,
*/
public static final String COMMA = ",";
/**
* COLON :
*/
public static final String COLON = ":";
/**
* SINGLE_SLASH /
*/
public static final String SINGLE_SLASH = "/";
/**
* DOUBLE_SLASH //
*/
public static final String DOUBLE_SLASH = "//";
/**
* SEMICOLON ;
*/
MICOLON = ";";
/**
* EQUAL SIGN
*/
public static final String EQUAL_SIGN = "="; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | /**
* ZOOKEEPER_SESSION_TIMEOUT
*/
public static final String ZOOKEEPER_SESSION_TIMEOUT = "zookeeper.session.timeout";
public static final String ZOOKEEPER_CONNECTION_TIMEOUT = "zookeeper.connection.timeout";
public static final String ZOOKEEPER_RETRY_SLEEP = "zookeeper.retry.sleep";
public static final String ZOOKEEPER_RETRY_MAXTIME = "zookeeper.retry.maxtime";
public static final String MASTER_HEARTBEAT_INTERVAL = "master.heartbeat.interval";
public static final String MASTER_EXEC_THREADS = "master.exec.threads";
public static final String MASTER_EXEC_TASK_THREADS = "master.exec.task.number";
public static final String MASTER_COMMIT_RETRY_TIMES = "master.task.commit.retryTimes";
public static final String MASTER_COMMIT_RETRY_INTERVAL = "master.task.commit.interval";
public static final String WORKER_EXEC_THREADS = "worker.exec.threads";
public static final String WORKER_HEARTBEAT_INTERVAL = "worker.heartbeat.interval";
public static final String WORKER_FETCH_TASK_NUM = "worker.fetch.task.num";
public static final String WORKER_MAX_CPULOAD_AVG = "worker.max.cpuload.avg";
public static final String WORKER_RESERVED_MEMORY = "worker.reserved.memory";
public static final String MASTER_MAX_CPULOAD_AVG = "master.max.cpuload.avg";
public static final String MASTER_RESERVED_MEMORY = "master.reserved.memory";
/**
* dolphinscheduler tasks queue
*/
public static final String DOLPHINSCHEDULER_TASKS_QUEUE = "tasks_queue";
/**
* dolphinscheduler need kill tasks queue
*/
public static final String DOLPHINSCHEDULER_TASKS_KILL = "tasks_kill";
public static final String ZOOKEEPER_DOLPHINSCHEDULER_ROOT = "zookeeper.dolphinscheduler.root";
public static final String SCHEDULER_QUEUE_IMPL = "dolphinscheduler.queue.impl";
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * date format of yyyy-MM-dd HH:mm:ss
*/
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
/**
* date format of yyyyMMddHHmmss
*/
public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
/**
* http connect time out
*/
public static final int HTTP_CONNECT_TIMEOUT = 60 * 1000;
/**
* http connect request time out
*/
public static final int HTTP_CONNECTION_REQUEST_TIMEOUT = 60 * 1000;
/**
* httpclient soceket time out
*/
public static final int SOCKET_TIMEOUT = 60 * 1000;
/**
* http header
*/
public static final String HTTP_HEADER_UNKNOWN = "unKnown";
/**
* http X-Forwarded-For
*/
public static final String HTTP_X_FORWARDED_FOR = "X-Forwarded-For";
/**
* http X-Real-IP
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final String HTTP_X_REAL_IP = "X-Real-IP";
/**
* UTF-8
*/
public static final String UTF_8 = "UTF-8";
/**
* user name regex
*/
public static final Pattern REGEX_USER_NAME = Pattern.compile("^[a-zA-Z0-9_-]{3,20}$");
/**
* email regex
*/
public static final Pattern REGEX_MAIL_NAME = Pattern.compile("^([a-z0-9A-Z]+[_|\\-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$");
/**
* read permission
*/
public static final int READ_PERMISSION = 2 * 1;
/**
* write permission
*/
public static final int WRITE_PERMISSION = 2 * 2;
/**
* execute permission
*/
public static final int EXECUTE_PERMISSION = 1;
/**
* default admin permission
*/
public static final int DEFAULT_ADMIN_PERMISSION = 7;
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * all permissions
*/
public static final int ALL_PERMISSIONS = READ_PERMISSION | WRITE_PERMISSION | EXECUTE_PERMISSION;
/**
* max task timeout
*/
public static final int MAX_TASK_TIMEOUT = 24 * 3600;
/**
* heartbeat threads number
*/
public static final int defaulWorkerHeartbeatThreadNum = 1;
/**
* heartbeat interval
*/
public static final int defaultWorkerHeartbeatInterval = 60;
/**
* worker fetch task number
*/
public static final int defaultWorkerFetchTaskNum = 1;
/**
* worker execute threads number
*/
public static final int defaultWorkerExecThreadNum = 10;
/**
* master cpu load
*/
public static final int defaultMasterCpuLoad = Runtime.getRuntime().availableProcessors() * 2;
/**
* master reserved memory
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final double defaultMasterReservedMemory = OSUtils.totalMemorySize() / 10;
/**
* worker cpu load
*/
public static final int defaultWorkerCpuLoad = Runtime.getRuntime().availableProcessors() * 2;
/**
* worker reserved memory
*/
public static final double defaultWorkerReservedMemory = OSUtils.totalMemorySize() / 10;
/**
* master execute threads number
*/
public static final int defaultMasterExecThreadNum = 100;
/**
* default master concurrent task execute num
*/
public static final int defaultMasterTaskExecNum = 20;
/**
* default log cache rows num,output when reach the number
*/
public static final int defaultLogRowsNum = 4 * 16;
/**
* log flush interval,output when reach the interval
*/
public static final int defaultLogFlushInterval = 1000;
/**
* default master heartbeat thread number
*/
public static final int defaulMasterHeartbeatThreadNum = 1;
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * default master heartbeat interval
*/
public static final int defaultMasterHeartbeatInterval = 60;
/**
* default master commit retry times
*/
public static final int defaultMasterCommitRetryTimes = 5;
/**
* default master commit retry interval
*/
public static final int defaultMasterCommitRetryInterval = 100;
/**
* time unit secong to minutes
*/
public static final int SEC_2_MINUTES_TIME_UNIT = 60;
/***
*
* rpc port
*/
public static final int RPC_PORT = 50051;
/**
* forbid running task
*/
public static final String FLOWNODE_RUN_FLAG_FORBIDDEN = "FORBIDDEN";
/**
* task record configuration path
*/
public static final String APPLICATION_PROPERTIES = "application-dao.properties";
public static final String TASK_RECORD_URL = "task.record.datasource.url";
public static final String TASK_RECORD_FLAG = "task.record.flag"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final String TASK_RECORD_USER = "task.record.datasource.username";
public static final String TASK_RECORD_PWD = "task.record.datasource.password";
public static final String DEFAULT = "Default";
public static final String USER = "user";
public static final String PASSWORD = "password";
public static final String XXXXXX = "******";
public static final String NULL = "NULL";
public static String TASK_RECORD_TABLE_HIVE_LOG = "eamp_hive_log_hd";
public static String TASK_RECORD_TABLE_HISTORY_HIVE_LOG = "eamp_hive_hist_log_hd";
/**
* command parameter keys
*/
public static final String CMDPARAM_RECOVER_PROCESS_ID_STRING = "ProcessInstanceId";
public static final String CMDPARAM_RECOVERY_START_NODE_STRING = "StartNodeIdList";
public static final String CMDPARAM_RECOVERY_WAITTING_THREAD = "WaittingThreadInstanceId";
public static final String CMDPARAM_SUB_PROCESS = "processInstanceId";
public static final String CMDPARAM_EMPTY_SUB_PROCESS = "0";
public static final String CMDPARAM_SUB_PROCESS_PARENT_INSTANCE_ID = "parentProcessInstanceId";
public static final String CMDPARAM_SUB_PROCESS_DEFINE_ID = "processDefinitionId";
public static final String CMDPARAM_START_NODE_NAMES = "StartNodeNameList";
/**
* complement data start date
*/
public static final String CMDPARAM_COMPLEMENT_DATA_START_DATE = "complementStartDate";
/**
* complement data end date
*/
public static final String CMDPARAM_COMPLEMENT_DATA_END_DATE = "complementEndDate";
/**
* hadoop configuration |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | */
public static final String HADOOP_RM_STATE_ACTIVE = "ACTIVE";
public static final String HADOOP_RM_STATE_STANDBY = "STANDBY";
public static final String HADOOP_RESOURCE_MANAGER_HTTPADDRESS_PORT = "resource.manager.httpaddress.port";
/**
* data source config
*/
public static final String SPRING_DATASOURCE_DRIVER_CLASS_NAME = "spring.datasource.driver-class-name";
public static final String SPRING_DATASOURCE_URL = "spring.datasource.url";
public static final String SPRING_DATASOURCE_USERNAME = "spring.datasource.username";
public static final String SPRING_DATASOURCE_PASSWORD = "spring.datasource.password";
public static final String SPRING_DATASOURCE_VALIDATION_QUERY_TIMEOUT = "spring.datasource.validationQueryTimeout";
public static final String SPRING_DATASOURCE_INITIAL_SIZE = "spring.datasource.initialSize";
public static final String SPRING_DATASOURCE_MIN_IDLE = "spring.datasource.minIdle";
public static final String SPRING_DATASOURCE_MAX_ACTIVE = "spring.datasource.maxActive";
public static final String SPRING_DATASOURCE_MAX_WAIT = "spring.datasource.maxWait";
public static final String SPRING_DATASOURCE_TIME_BETWEEN_EVICTION_RUNS_MILLIS = "spring.datasource.timeBetweenEvictionRunsMillis";
public static final String SPRING_DATASOURCE_TIME_BETWEEN_CONNECT_ERROR_MILLIS = "spring.datasource.timeBetweenConnectErrorMillis";
public static final String SPRING_DATASOURCE_MIN_EVICTABLE_IDLE_TIME_MILLIS = "spring.datasource.minEvictableIdleTimeMillis";
public static final String SPRING_DATASOURCE_VALIDATION_QUERY = "spring.datasource.validationQuery";
public static final String SPRING_DATASOURCE_TEST_WHILE_IDLE = "spring.datasource.testWhileIdle";
public static final String SPRING_DATASOURCE_TEST_ON_BORROW = "spring.datasource.testOnBorrow";
public static final String SPRING_DATASOURCE_TEST_ON_RETURN = "spring.datasource.testOnReturn";
public static final String SPRING_DATASOURCE_POOL_PREPARED_STATEMENTS = "spring.datasource.poolPreparedStatements";
public static final String SPRING_DATASOURCE_DEFAULT_AUTO_COMMIT = "spring.datasource.defaultAutoCommit";
public static final String SPRING_DATASOURCE_KEEP_ALIVE = "spring.datasource.keepAlive";
public static final String SPRING_DATASOURCE_MAX_POOL_PREPARED_STATEMENT_PER_CONNECTION_SIZE = "spring.datasource.maxPoolPreparedStatementPerConnectionSize";
public static final String DEVELOPMENT = "development";
public static final String QUARTZ_PROPERTIES_PATH = "quartz.properties";
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * sleep time
*/
public static final int SLEEP_TIME_MILLIS = 1000;
/**
* heartbeat for zk info length
*/
public static final int HEARTBEAT_FOR_ZOOKEEPER_INFO_LENGTH = 7;
/**
* hadoop params constant
*/
/**
* jar
*/
public static final String JAR = "jar";
/**
* hadoop
*/
public static final String HADOOP = "hadoop";
/**
* -D parameter
*/
public static final String D = "-D";
/**
* -D mapreduce.job.queuename=ququename
*/
public static final String MR_QUEUE = "mapreduce.job.queuename";
/**
* spark params constant
*/
public static final String MASTER = "--master"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final String DEPLOY_MODE = "--deploy-mode";
/**
* --class CLASS_NAME
*/
public static final String MAIN_CLASS = "--class";
/**
* --driver-cores NUM
*/
public static final String DRIVER_CORES = "--driver-cores";
/**
* --driver-memory MEM
*/
public static final String DRIVER_MEMORY = "--driver-memory";
/**
* --num-executors NUM
*/
public static final String NUM_EXECUTORS = "--num-executors";
/**
* --executor-cores NUM
*/
public static final String EXECUTOR_CORES = "--executor-cores";
/**
* --executor-memory MEM
*/
public static final String EXECUTOR_MEMORY = "--executor-memory";
/**
* --queue QUEUE
*/
public static final String SPARK_QUEUE = "--queue";
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * --queue --qu
*/
public static final String FLINK_QUEUE = "--qu";
/**
* exit code success
*/
public static final int EXIT_CODE_SUCCESS = 0;
/**
* exit code kill
*/
public static final int EXIT_CODE_KILL = 137;
/**
* exit code failure
*/
public static final int EXIT_CODE_FAILURE = -1;
/**
* date format of yyyyMMdd
*/
public static final String PARAMETER_FORMAT_DATE = "yyyyMMdd";
/**
* date format of yyyyMMddHHmmss
*/
public static final String PARAMETER_FORMAT_TIME = "yyyyMMddHHmmss";
/**
* system date(yyyyMMddHHmmss)
*/
public static final String PARAMETER_DATETIME = "system.datetime";
/**
* system date(yyyymmdd) today
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final String PARAMETER_CURRENT_DATE = "system.biz.curdate";
/**
* system date(yyyymmdd) yesterday
*/
public static final String PARAMETER_BUSINESS_DATE = "system.biz.date";
/**
* ACCEPTED
*/
public static final String ACCEPTED = "ACCEPTED";
/**
* SUCCEEDED
*/
public static final String SUCCEEDED = "SUCCEEDED";
/**
* NEW
*/
public static final String NEW = "NEW";
/**
* NEW_SAVING
*/
public static final String NEW_SAVING = "NEW_SAVING";
/**
* SUBMITTED
*/
public static final String SUBMITTED = "SUBMITTED";
/**
* FAILED
*/
public static final String FAILED = "FAILED";
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * KILLED
*/
public static final String KILLED = "KILLED";
/**
* RUNNING
*/
public static final String RUNNING = "RUNNING";
/**
* underline "_"
*/
public static final String UNDERLINE = "_";
/**
* quartz job prifix
*/
public static final String QUARTZ_JOB_PRIFIX = "job";
/**
* quartz job group prifix
*/
public static final String QUARTZ_JOB_GROUP_PRIFIX = "jobgroup";
/**
* projectId
*/
public static final String PROJECT_ID = "projectId";
/**
* processId
*/
public static final String SCHEDULE_ID = "scheduleId";
/**
* schedule
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final String SCHEDULE = "schedule";
/**
* application regex
*/
public static final String APPLICATION_REGEX = "application_\\d+_\\d+";
public static final String PID = "pid";
/**
* month_begin
*/
public static final String MONTH_BEGIN = "month_begin";
/**
* add_months
*/
public static final String ADD_MONTHS = "add_months";
/**
* month_end
*/
public static final String MONTH_END = "month_end";
/**
* week_begin
*/
public static final String WEEK_BEGIN = "week_begin";
/**
* week_end
*/
public static final String WEEK_END = "week_end";
/**
* timestamp
*/
public static final String TIMESTAMP = "timestamp"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final char SUBTRACT_CHAR = '-';
public static final char ADD_CHAR = '+';
public static final char MULTIPLY_CHAR = '*';
public static final char DIVISION_CHAR = '/';
public static final char LEFT_BRACE_CHAR = '(';
public static final char RIGHT_BRACE_CHAR = ')';
public static final String ADD_STRING = "+";
public static final String MULTIPLY_STRING = "*";
public static final String DIVISION_STRING = "/";
public static final String LEFT_BRACE_STRING = "(";
public static final char P = 'P';
public static final char N = 'N';
public static final String SUBTRACT_STRING = "-";
public static final String GLOBAL_PARAMS = "globalParams";
public static final String LOCAL_PARAMS = "localParams";
public static final String PROCESS_INSTANCE_STATE = "processInstanceState";
public static final String TASK_LIST = "taskList";
public static final String RWXR_XR_X = "rwxr-xr-x";
/**
* master/worker server use for zk
*/
public static final String MASTER_PREFIX = "master";
public static final String WORKER_PREFIX = "worker";
public static final String DELETE_ZK_OP = "delete";
public static final String ADD_ZK_OP = "add";
public static final String ALIAS = "alias";
public static final String CONTENT = "content";
public static final String DEPENDENT_SPLIT = ":||";
public static final String DEPENDENT_ALL = "ALL";
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * preview schedule execute count
*/
public static final int PREVIEW_SCHEDULE_EXECUTE_COUNT = 5;
/**
* kerberos
*/
public static final String KERBEROS = "kerberos";
/**
* java.security.krb5.conf
*/
public static final String JAVA_SECURITY_KRB5_CONF = "java.security.krb5.conf";
/**
* java.security.krb5.conf.path
*/
public static final String JAVA_SECURITY_KRB5_CONF_PATH = "java.security.krb5.conf.path";
/**
* hadoop.security.authentication
*/
public static final String HADOOP_SECURITY_AUTHENTICATION = "hadoop.security.authentication";
/**
* hadoop.security.authentication
*/
public static final String HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE = "hadoop.security.authentication.startup.state";
/**
* loginUserFromKeytab user
*/
public static final String LOGIN_USER_KEY_TAB_USERNAME = "login.user.keytab.username";
/**
* default worker group id
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final int DEFAULT_WORKER_ID = -1;
/**
* loginUserFromKeytab path
*/
public static final String LOGIN_USER_KEY_TAB_PATH = "login.user.keytab.path";
/**
* task log info format
*/
public static final String TASK_LOG_INFO_FORMAT = "TaskLogInfo-%s";
/**
* hive conf
*/
public static final String HIVE_CONF = "hiveconf:";
//flink 任务
public static final String FLINK_YARN_CLUSTER = "yarn-cluster";
public static final String FLINK_RUN_MODE = "-m";
public static final String FLINK_YARN_SLOT = "-ys";
public static final String FLINK_APP_NAME = "-ynm";
public static final String FLINK_TASK_MANAGE = "-yn";
public static final String FLINK_JOB_MANAGE_MEM = "-yjm";
public static final String FLINK_TASK_MANAGE_MEM = "-ytm";
public static final String FLINK_detach = "-d";
public static final String FLINK_MAIN_CLASS = "-c";
public static final int[] NOT_TERMINATED_STATES = new int[]{
ExecutionStatus.SUBMITTED_SUCCESS.ordinal(),
ExecutionStatus.RUNNING_EXEUTION.ordinal(),
ExecutionStatus.READY_PAUSE.ordinal(),
ExecutionStatus.READY_STOP.ordinal(),
ExecutionStatus.NEED_FAULT_TOLERANCE.ordinal(),
ExecutionStatus.WAITTING_THREAD.ordinal(), |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | ExecutionStatus.WAITTING_DEPEND.ordinal()
};
/**
* status
*/
public static final String STATUS = "status";
/**
* message
*/
public static final String MSG = "msg";
/**
* data total
* 数据总数
*/
public static final String COUNT = "count";
/**
* page size
* 每页数据条数
*/
public static final String PAGE_SIZE = "pageSize";
/**
* current page no
* 当前页码
*/
public static final String PAGE_NUMBER = "pageNo";
/**
* result
*/
publSULT = "result";
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | *
*/
public statTA_LIST = "data";
public static final String TOTAL_LIST = "totalList";
public static final String CURRENT_PAGE = "currentPage";
public static final String TOTAL_PAGE = "totalPage";
public static final String TOTAL = "total";
/**
* session user
*/
SSION_USER = "session.user";
SSION_ID = "sessionId";
public static final String PASSWORD_DEFAULT = "******";
/**
* driver
*/
publG_POSTGRESQL_DRIVER = "org.postgresql.Driver";
public static final String COM_MYSQL_JDBC_DRIVER = "com.mysql.jdbc.Driver";
publG_APACHE_HIVE_JDBC_HIVE_DRIVER = "org.apache.hive.jdbc.HiveDriver";
public static final String COM_CLICKHOUSE_JDBC_DRIVER = "ru.yandex.clickhouse.ClickHouseDriver";
public static final String COM_ORACLE_JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
public static final String COM_SQLSERVER_JDBC_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
public static final String COM_DB2_JDBC_DRIVER = "com.ibm.db2.jcc.DB2Driver";
/**
* database type
*/
SQL = "MYSQL";
public static final String POSTGRESQL = "POSTGRESQL";
public static final String HIVE = "HIVE";
public static final String SPARK = "SPARK"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,441 | [Feature] add user error when user name contains '.' | **Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'
i think maybe the username regex string is error.
| https://github.com/apache/dolphinscheduler/issues/1441 | https://github.com/apache/dolphinscheduler/pull/1445 | b276ece5727bdf7cecc07bfc888f27cb75726b65 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | "2019-12-11T03:07:47Z" | java | "2019-12-12T06:19:55Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final String CLICKHOUSE = "CLICKHOUSE";
publACLE = "ORACLE";
public static final String SQLSERVER = "SQLSERVER";
public static final String DB2 = "DB2";
/**
* jdbc url
*/
puBC_MYSQL = "jdbc:mysql://";
puBC_POSTGRESQL = "jdbc:postgresql://";
puBC_HIVE_2 = "jdbc:hive2://";
puBC_CLICKHOUSE = "jdbc:clickhouse://";
puBC_ORACLE = "jdbc:oracle:thin:@//";
puBC_SQLSERVER = "jdbc:sqlserver://";
puBC_DB2 = "jdbc:db2://";
public static final String ADDRESS = "address";
public statTABASE = "database";
puBC_URL = "jdbcUrl";
public static final String PRINCIPAL = "principal";
public static final String OTHER = "other";
/**
* session timeout
*/
ON_TIME_OUT = 7200;
public static final int maxFileSize = 1024 * 1024 * 1024;
public static final String UDF = "UDF";
public static final String CLASS = "class";
publCEIVERS = "receivers";
publCEIVERS_CC = "receiversCc";
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,442 | [BUG] code comment error |
**Describe the bug**
in this class: org.apache.dolphinscheduler.server.master.runner.MasterSchedulerThread. the line number 104, zkMasterClient.getMasterLockPath() The lock path obtained may should be /dolphinscheduler/lock/masters, but in the comment, is's /dolphinscheduler/lock/failover/master, I think it's easy to mislead people who read the source code, please check this, if it does, I can open a pr to fix it
**To Reproduce**
None
**Expected behavior**
Node
**Screenshots**
None
**Which version of Dolphin Scheduler:**
latest version
**Additional context**
None
**Requirement or improvement
None
| https://github.com/apache/dolphinscheduler/issues/1442 | https://github.com/apache/dolphinscheduler/pull/1446 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | 9a3a6f5a3d5ec613b49ae1a5a947d58c351f1fc7 | "2019-12-11T03:47:22Z" | java | "2019-12-12T06:20:27Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerThread.java | /*
* 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
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,442 | [BUG] code comment error |
**Describe the bug**
in this class: org.apache.dolphinscheduler.server.master.runner.MasterSchedulerThread. the line number 104, zkMasterClient.getMasterLockPath() The lock path obtained may should be /dolphinscheduler/lock/masters, but in the comment, is's /dolphinscheduler/lock/failover/master, I think it's easy to mislead people who read the source code, please check this, if it does, I can open a pr to fix it
**To Reproduce**
None
**Expected behavior**
Node
**Screenshots**
None
**Which version of Dolphin Scheduler:**
latest version
**Additional context**
None
**Requirement or improvement
None
| https://github.com/apache/dolphinscheduler/issues/1442 | https://github.com/apache/dolphinscheduler/pull/1446 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | 9a3a6f5a3d5ec613b49ae1a5a947d58c351f1fc7 | "2019-12-11T03:47:22Z" | java | "2019-12-12T06:20:27Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerThread.java | * 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.dolphinscheduler.server.master.runner;
import org.apache.curator.framework.imps.CuratorFrameworkState;
import org.apache.curator.framework.recipes.locks.InterProcessMutex;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.thread.Stopper;
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
import org.apache.dolphinscheduler.common.utils.OSUtils;
import org.apache.dolphinscheduler.common.zk.AbstractZKClient;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.dao.entity.Command;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
import org.apache.dolphinscheduler.server.utils.SpringApplicationContext;
import org.apache.dolphinscheduler.server.zk.ZKMasterClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
/**
* master scheduler thread
*/
public class MasterSchedulerThread implements Runnable { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,442 | [BUG] code comment error |
**Describe the bug**
in this class: org.apache.dolphinscheduler.server.master.runner.MasterSchedulerThread. the line number 104, zkMasterClient.getMasterLockPath() The lock path obtained may should be /dolphinscheduler/lock/masters, but in the comment, is's /dolphinscheduler/lock/failover/master, I think it's easy to mislead people who read the source code, please check this, if it does, I can open a pr to fix it
**To Reproduce**
None
**Expected behavior**
Node
**Screenshots**
None
**Which version of Dolphin Scheduler:**
latest version
**Additional context**
None
**Requirement or improvement
None
| https://github.com/apache/dolphinscheduler/issues/1442 | https://github.com/apache/dolphinscheduler/pull/1446 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | 9a3a6f5a3d5ec613b49ae1a5a947d58c351f1fc7 | "2019-12-11T03:47:22Z" | java | "2019-12-12T06:20:27Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerThread.java | /**
* logger of MasterSchedulerThread
*/
private static final Logger logger = LoggerFactory.getLogger(MasterSchedulerThread.class);
/**
* master exec service
*/
private final ExecutorService masterExecService;
/**
* dolphinscheduler database interface
*/
private final ProcessDao processDao;
/**
* zookeeper master client
*/
private final ZKMasterClient zkMasterClient ;
/**
* master exec thread num
*/
private int masterExecThreadNum;
/**
* master config
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,442 | [BUG] code comment error |
**Describe the bug**
in this class: org.apache.dolphinscheduler.server.master.runner.MasterSchedulerThread. the line number 104, zkMasterClient.getMasterLockPath() The lock path obtained may should be /dolphinscheduler/lock/masters, but in the comment, is's /dolphinscheduler/lock/failover/master, I think it's easy to mislead people who read the source code, please check this, if it does, I can open a pr to fix it
**To Reproduce**
None
**Expected behavior**
Node
**Screenshots**
None
**Which version of Dolphin Scheduler:**
latest version
**Additional context**
None
**Requirement or improvement
None
| https://github.com/apache/dolphinscheduler/issues/1442 | https://github.com/apache/dolphinscheduler/pull/1446 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | 9a3a6f5a3d5ec613b49ae1a5a947d58c351f1fc7 | "2019-12-11T03:47:22Z" | java | "2019-12-12T06:20:27Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerThread.java | private MasterConfig masterConfig;
/**
* constructor of MasterSchedulerThread
* @param zkClient zookeeper master client
* @param processDao process dao
* @param masterExecThreadNum master exec thread num
*/
public MasterSchedulerThread(ZKMasterClient zkClient, ProcessDao processDao, int masterExecThreadNum){
this.processDao = processDao;
this.zkMasterClient = zkClient;
this.masterExecThreadNum = masterExecThreadNum;
this.masterExecService = ThreadUtils.newDaemonFixedThreadExecutor("Master-Exec-Thread",masterExecThreadNum);
this.masterConfig = SpringApplicationContext.getBean(MasterConfig.class);
}
/**
* run of MasterSchedulerThread
*/
@Override
public void run() {
while (Stopper.isRunning()){
ProcessInstance processInstance = null;
InterProcessMutex mutex = null;
try {
if(OSUtils.checkResource(masterConfig.getMasterMaxCpuloadAvg(), masterConfig.getMasterReservedMemory())){
if (zkMasterClient.getZkClient().getState() == CuratorFrameworkState.STARTED) {
String znodeLock = zkMasterClient.getMasterLockPath();
mutex = new InterProcessMutex(zkMasterClient.getZkClient(), znodeLock);
mutex.acquire(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 1,442 | [BUG] code comment error |
**Describe the bug**
in this class: org.apache.dolphinscheduler.server.master.runner.MasterSchedulerThread. the line number 104, zkMasterClient.getMasterLockPath() The lock path obtained may should be /dolphinscheduler/lock/masters, but in the comment, is's /dolphinscheduler/lock/failover/master, I think it's easy to mislead people who read the source code, please check this, if it does, I can open a pr to fix it
**To Reproduce**
None
**Expected behavior**
Node
**Screenshots**
None
**Which version of Dolphin Scheduler:**
latest version
**Additional context**
None
**Requirement or improvement
None
| https://github.com/apache/dolphinscheduler/issues/1442 | https://github.com/apache/dolphinscheduler/pull/1446 | a1ded5ee041a387d56757fcdd27e39efd3a6000a | 9a3a6f5a3d5ec613b49ae1a5a947d58c351f1fc7 | "2019-12-11T03:47:22Z" | java | "2019-12-12T06:20:27Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerThread.java | ThreadPoolExecutor poolExecutor = (ThreadPoolExecutor) masterExecService;
int activeCount = poolExecutor.getActiveCount();
Command command = processDao.findOneCommand();
if (command != null) {
logger.info(String.format("find one command: id: %d, type: %s", command.getId(),command.getCommandType().toString()));
try{
processInstance = processDao.handleCommand(logger, OSUtils.getHost(), this.masterExecThreadNum - activeCount, command);
if (processInstance != null) {
logger.info("start master exec thread , split DAG ...");
masterExecService.execute(new MasterExecThread(processInstance,processDao));
}
}catch (Exception e){
logger.error("scan command error ", e);
processDao.moveToErrorCommand(command, e.toString());
}
}
}
}
Thread.sleep(Constants.SLEEP_TIME_MILLIS);
}catch (Exception e){
logger.error("master scheduler thread exception : " + e.getMessage(),e);
}finally{
AbstractZKClient.releaseMutex(mutex);
}
}
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | /*
* 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.
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | package org.apache.dolphinscheduler.common.utils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.shell.ShellExecutor;
import org.apache.commons.configuration.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.GlobalMemory;
import oshi.hardware.HardwareAbstractionLayer;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.math.RoundingMode;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
/**
* os utils
*
*/
public class OSUtils { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | private static final Logger logger = LoggerFactory.getLogger(OSUtils.class);
private static final SystemInfo SI = new SystemInfo();
public static final String TWO_DECIMAL = "0.00";
private static HardwareAbstractionLayer hal = SI.getHardware();
private OSUtils() {}
/**
* get memory usage
* Keep 2 decimal
* @return percent %
*/
public static double memoryUsage() {
GlobalMemory memory = hal.getMemory();
double memoryUsage = (memory.getTotal() - memory.getAvailable() - memory.getSwapUsed()) * 0.1 / memory.getTotal() * 10;
DecimalFormat df = new DecimalFormat(TWO_DECIMAL);
df.setRoundingMode(RoundingMode.HALF_UP);
return Double.parseDouble(df.format(memoryUsage)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | }
/**
* get available physical memory size
*
* Keep 2 decimal
* @return available Physical Memory Size, unit: G
*/
public static double availablePhysicalMemorySize() {
GlobalMemory memory = hal.getMemory();
double availablePhysicalMemorySize = (memory.getAvailable() + memory.getSwapUsed()) /1024.0/1024/1024;
DecimalFormat df = new DecimalFormat(TWO_DECIMAL);
df.setRoundingMode(RoundingMode.HALF_UP);
return Double.parseDouble(df.format(availablePhysicalMemorySize));
}
/**
* get total physical memory size
*
* Keep 2 decimal
* @return available Physical Memory Size, unit: G
*/
public static double totalMemorySize() {
GlobalMemory memory = hal.getMemory();
double availablePhysicalMemorySize = memory.getTotal() /1024.0/1024/1024;
DecimalFormat df = new DecimalFormat(TWO_DECIMAL);
df.setRoundingMode(RoundingMode.HALF_UP);
return Double.parseDouble(df.format(availablePhysicalMemorySize));
}
/**
* load average
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | * @return load average
*/
public static double loadAverage() {
double loadAverage = hal.getProcessor().getSystemLoadAverage();
DecimalFormat df = new DecimalFormat(TWO_DECIMAL);
df.setRoundingMode(RoundingMode.HALF_UP);
return Double.parseDouble(df.format(loadAverage));
}
/**
* get cpu usage
*
* @return cpu usage
*/
public static double cpuUsage() {
CentralProcessor processor = hal.getProcessor();
double cpuUsage = processor.getSystemCpuLoad();
DecimalFormat df = new DecimalFormat(TWO_DECIMAL);
df.setRoundingMode(RoundingMode.HALF_UP);
return Double.parseDouble(df.format(cpuUsage));
}
public static List<String> getUserList() {
try {
if (isMacOS()) {
return getUserListFromMac();
} else if (isWindows()) {
return getUserListFromWindows();
} else {
return getUserListFromLinux();
}
} catch (Exception e) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | logger.error(e.getMessage(), e);
}
return Collections.emptyList();
}
/**
* get user list from linux
*
* @return user list
*/
private static List<String> getUserListFromLinux() throws IOException {
List<String> userList = new ArrayList<>();
try (BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(new FileInputStream("/etc/passwd")))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
if (line.contains(":")) {
String[] userInfo = line.split(":");
userList.add(userInfo[0]);
}
}
}
return userList;
}
/**
* get user list from mac
* @return user list
*/
private static List<String> getUserListFromMac() throws IOException {
String result = exeCmd("dscl . list /users");
if (StringUtils.isNotEmpty(result)) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | return Arrays.asList(result.split( "\n"));
}
return Collections.emptyList();
}
/**
* get user list from windows
* @return user list
* @throws IOException
*/
private static List<String> getUserListFromWindows() throws IOException {
String result = exeCmd("net user");
String[] lines = result.split("\n");
int startPos = 0;
int endPos = lines.length - 2;
for (int i = 0; i < lines.length; i++) {
if (lines[i].isEmpty()) {
continue;
}
int count = 0;
if (lines[i].charAt(0) == '-') {
for (int j = 0; j < lines[i].length(); j++) {
if (lines[i].charAt(i) == '-') {
count++;
}
}
}
if (count == lines[i].length()) {
startPos = i + 1;
break;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | }
List<String> users = new ArrayList<>();
while (startPos <= endPos) {
Pattern pattern = Pattern.compile("\\s+");
users.addAll(Arrays.asList(pattern.split(lines[startPos])));
startPos++;
}
return users;
}
/**
* create user
* @param userName user name
* @return true if creation was successful, otherwise false
*/
public static boolean createUser(String userName) {
try {
String userGroup = OSUtils.getGroup();
if (StringUtils.isEmpty(userGroup)) {
logger.error("{} group does not exist for this operating system.", userGroup);
return false;
}
if (isMacOS()) {
createMacUser(userName, userGroup);
} else if (isWindows()) {
createWindowsUser(userName, userGroup);
} else {
createLinuxUser(userName, userGroup);
}
return true;
} catch (Exception e) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | logger.error(e.getMessage(), e);
}
return false;
}
/**
* create linux user
* @param userName user name
* @param userGroup user group
* @throws IOException in case of an I/O error
*/
private static void createLinuxUser(String userName, String userGroup) throws IOException {
logger.info("create linux os user : {}", userName);
String cmd = String.format("sudo useradd -g %s %s", userGroup, userName);
logger.info("execute cmd : {}", cmd);
OSUtils.exeCmd(cmd);
}
/**
* create mac user (Supports Mac OSX 10.10+)
* @param userName user name
* @param userGroup user group
* @throws IOException in case of an I/O error
*/
private static void createMacUser(String userName, String userGroup) throws IOException {
logger.info("create mac os user : {}", userName);
String userCreateCmd = String.format("sudo sysadminctl -addUser %s -password %s", userName, userName);
String appendGroupCmd = String.format("sudo dseditgroup -o edit -a %s -t user %s", userName, userGroup);
logger.info("create user command : {}", userCreateCmd);
OSUtils.exeCmd(userCreateCmd);
logger.info("append user to group : {}", appendGroupCmd);
OSUtils.exeCmd(appendGroupCmd); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | }
/**
* create windows user
* @param userName user name
* @param userGroup user group
* @throws IOException in case of an I/O error
*/
private static void createWindowsUser(String userName, String userGroup) throws IOException {
logger.info("create windows os user : {}", userName);
String userCreateCmd = String.format("net user \"%s\" /add", userName);
String appendGroupCmd = String.format("net localgroup \"%s\" \"%s\" /add", userGroup, userName);
logger.info("execute create user command : {}", userCreateCmd);
OSUtils.exeCmd(userCreateCmd);
logger.info("execute append user to group : {}", appendGroupCmd);
OSUtils.exeCmd(appendGroupCmd);
}
/**
* get system group information
* @return system group info
* @throws IOException errors
*/
public static String getGroup() throws IOException {
if (isWindows()) {
String currentProcUserName = System.getProperty("user.name");
String result = exeCmd(String.format("net user \"%s\"", currentProcUserName));
String line = result.split("\n")[22];
String group = Pattern.compile("\\s+").split(line)[1];
if (group.charAt(0) == '*') {
return group.substring(1);
} else { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | return group;
}
} else {
String result = exeCmd("groups");
if (StringUtils.isNotEmpty(result)) {
String[] groupInfo = result.split(" ");
return groupInfo[0];
}
}
return null;
}
/**
* Execute the corresponding command of Linux or Windows
*
* @param command command
* @return result of execute command
* @throws IOException errors
*/
public static String exeCmd(String command) throws IOException {
BufferedReader br = null;
try {
Process p = Runtime.getRuntime().exec(command);
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
StringBuilder sb = new StringBuilder();
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
return sb.toString();
} finally { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | if (br != null) {
try {
br.close();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
}
/**
* Execute the shell
* @param command command
* @return result of execute the shell
* @throws IOException errors
*/
public static String exeShell(String command) throws IOException {
return ShellExecutor.execCommand(command);
}
/**
* get process id
* @return process id
*/
public static int getProcessID() {
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
return Integer.parseInt(runtimeMXBean.getName().split("@")[0]);
}
/**
* get local host
* @return host
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | public static String getHost(){
try {
return InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
logger.error(e.getMessage(),e);
}
return null;
}
/**
* whether is macOS
* @return true if mac
*/
public static boolean isMacOS() {
String os = System.getProperty("os.name");
return os.startsWith("Mac");
}
/**
* whether is windows
* @return true if windows
*/
public static boolean isWindows() {
String os = System.getProperty("os.name");
return os.startsWith("Windows");
}
/**
* check memory and cpu usage
* @return check memory and cpu usage
*/
public static Boolean checkResource(double systemCpuLoad, double systemReservedMemory){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java | double loadAverage = OSUtils.loadAverage();
double availablePhysicalMemorySize = OSUtils.availablePhysicalMemorySize();
if(loadAverage > systemCpuLoad || availablePhysicalMemorySize < systemReservedMemory){
logger.warn("load or availablePhysicalMemorySize(G) is too high, it's availablePhysicalMemorySize(G):{},loadAvg:{}", availablePhysicalMemorySize , loadAverage);
return false;
}else{
return true;
}
}
/**
* check memory and cpu usage
* @param conf conf
* @param isMaster is master
* @return check memory and cpu usage
*/
public static Boolean checkResource(Configuration conf, Boolean isMaster){
double systemCpuLoad;
double systemReservedMemory;
if(Boolean.TRUE.equals(isMaster)){
systemCpuLoad = conf.getDouble(Constants.MASTER_MAX_CPULOAD_AVG, Constants.DEFAULT_MASTER_CPU_LOAD);
systemReservedMemory = conf.getDouble(Constants.MASTER_RESERVED_MEMORY, Constants.DEFAULT_MASTER_RESERVED_MEMORY);
}else{
systemCpuLoad = conf.getDouble(Constants.WORKER_MAX_CPULOAD_AVG, Constants.DEFAULT_WORKER_CPU_LOAD);
systemReservedMemory = conf.getDouble(Constants.WORKER_RESERVED_MEMORY, Constants.DEFAULT_WORKER_RESERVED_MEMORY);
}
return checkResource(systemCpuLoad,systemReservedMemory);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/process/ProcessImplForWin32.java | /* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/process/ProcessImplForWin32.java | * 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.dolphinscheduler.common.utils.process;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.*;
import com.sun.jna.ptr.IntByReference;
import sun.security.action.GetPropertyAction;
import java.io.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.sun.jna.platform.win32.WinBase.STILL_ACTIVE;
public class ProcessImplForWin32 extends Process { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/process/ProcessImplForWin32.java | private static final sun.misc.JavaIOFileDescriptorAccess fdAccess
= sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess();
private static final int PIPE_SIZE = 4096 + 24;
private static final int HANDLE_STORAGE_SIZE = 6;
private static final int OFFSET_READ = 0;
private static final int OFFSET_WRITE = 1;
private static final WinNT.HANDLE JAVA_INVALID_HANDLE_VALUE = new WinNT.HANDLE(Pointer.createConstant(-1));
/**
* Open a file for writing. If {@code append} is {@code true} then the file
* is opened for atomic append directly and a FileOutputStream constructed
* with the resulting handle. This is because a FileOutputStream created
* to append to a file does not open the file in a manner that guarantees
* that writes by the child process will be atomic.
*/
private static FileOutputStream newFileOutputStream(File f, boolean append)
throws IOException
{
if (append) {
String path = f.getPath();
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkWrite(path);
long handle = openForAtomicAppend(path);
final FileDescriptor fd = new FileDescriptor();
fdAccess.setHandle(fd, handle);
return AccessController.doPrivileged(
new PrivilegedAction<FileOutputStream>() {
public FileOutputStream run() {
return new FileOutputStream(fd);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 2,111 | [BUG] sun.misc.JavaIOFileDescriptorAccess is not portable | Current implementation relies on `sun.misc.JavaIOFileDescriptorAccess` which is only accessible on oraclejdk8.
Basically the demand is getting & setting `field` field of `FileDescriptor`, so we can directly do that with reflection.
Though, I suspect the necessity we introduce `ProcessImplForWin32`. Maybe we could have a better way to support worker server to run bat script. | https://github.com/apache/dolphinscheduler/issues/2111 | https://github.com/apache/dolphinscheduler/pull/2113 | 450a1f56fc73f088fce89a343a0b008706f2088c | 9224b49b58b756d22c75d8929108f716283282b4 | "2020-03-08T05:09:46Z" | java | "2020-03-09T11:06:41Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/process/ProcessImplForWin32.java | }
);
} else {
return new FileOutputStream(f);
}
}
static Process start(String username,
String password,
String cmdarray[],
java.util.Map<String,String> environment,
String dir,
ProcessBuilderForWin32.Redirect[] redirects,
boolean redirectErrorStream)
throws IOException
{
String envblock = ProcessEnvironmentForWin32.toEnvironmentBlock(environment);
FileInputStream f0 = null;
FileOutputStream f1 = null;
FileOutputStream f2 = null;
try {
long[] stdHandles;
if (redirects == null) {
stdHandles = new long[] { -1L, -1L, -1L };
} else {
stdHandles = new long[3];
if (redirects[0] == ProcessBuilderForWin32.Redirect.PIPE)
stdHandles[0] = -1L;
else if (redirects[0] == ProcessBuilderForWin32.Redirect.INHERIT)
stdHandles[0] = fdAccess.getHandle(FileDescriptor.in); |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.