SemyonSinchenko commented on code in PR #616:
URL: https://github.com/apache/incubator-graphar/pull/616#discussion_r1823251162


##########
cli/src/graphar_cli/config.py:
##########
@@ -0,0 +1,253 @@
+# 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.
+
+from logging import getLogger
+from pathlib import Path
+from typing import Dict, List, Literal, Optional  # TODO: move to the 
TYPE_CHECKING block
+
+from pydantic import BaseModel, field_validator, model_validator
+from typing_extensions import Self
+
+logger = getLogger("graphar_cli")
+
+# TODO: move them to constants.py
+
+DEFAULT_FILE_TYPE = "parquet"
+DEFAULT_ADJ_LIST_TYPE = "ordered_by_source"
+DEFAULT_REGULAR_SEPARATOR = "_"
+DEFAULT_VALIDATE_LEVEL = "weak"
+DEFAULT_VERSION = "gar/v1"
+SUPPORT_FILE_TYPES = {"parquet", "orc", "csv", "json"}
+
+class GraphArConfig(BaseModel):
+    path: str
+    name: str
+    vertex_chunk_size: Optional[int] = 100
+    edge_chunk_size: Optional[int] = 1024
+    file_type: Literal["parquet", "orc", "csv", "json"] = DEFAULT_FILE_TYPE

Review Comment:
   I'm just curious what was the reason to use strings instead of creating a 
enumeration? I the `file_type` in at least four places and it may become 
challenging to support it in the future... What do you think about something 
like this:
   ```python
   from enum import Enum
   
   class FileType(str, Enum):
       PARQUET = "parquet"
       ORC = "orc"
       CSV = "csv"
       JSON = "json"
   ```
   and use it instead of the string literals?
   
   That also allows to avoid checking it each time like this `if file_type not 
in SUPPORT_FILE_TYPES:`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@graphar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@graphar.apache.org
For additional commands, e-mail: commits-h...@graphar.apache.org

Reply via email to