Skip to content

Commit

Permalink
fix config type
Browse files Browse the repository at this point in the history
  • Loading branch information
jasinliu committed Oct 30, 2024
1 parent 18ba462 commit 4af9117
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 232 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
graphar check -p ../testing/neo4j/MovieGraph.graph.yml
graphar show -p ../testing/neo4j/MovieGraph.graph.yml -v Person
graphar show -p ../testing/neo4j/MovieGraph.graph.yml -es Person -e ACTED_IN -ed Movie
graphar import -c import.mini.yml
graphar import -c ../testing/neo4j/data/import.mini.yml
# TODO: Add unit tests


Expand All @@ -84,7 +84,8 @@ jobs:
macos:
name: ${{ matrix.architecture }} macOS ${{ matrix.macos-version }} CLI
runs-on: macos-${{ matrix.macos-version }}
if: false
# TODO: Remove this when the macos issue is fixed
if: false
strategy:
fail-fast: false
matrix:
Expand All @@ -111,6 +112,6 @@ jobs:
graphar check -p ../testing/neo4j/MovieGraph.graph.yml
graphar show -p ../testing/neo4j/MovieGraph.graph.yml -v Person
graphar show -p ../testing/neo4j/MovieGraph.graph.yml -es Person -e ACTED_IN -ed Movie
graphar import -c import.full.yml
graphar import -c ../testing/neo4j/data/import.mini.yml
# TODO: Add unit tests
7 changes: 3 additions & 4 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,20 @@ graphar show -p ../testing/neo4j/MovieGraph.graph.yml -v Person
graphar show -p ../testing/neo4j/MovieGraph.graph.yml -es Person -e ACTED_IN -ed Movie

# import graph data by using a config file
graphar import -c import.mini.yml
graphar import -c ../testing/neo4j/data/import.mini.yml
```

## Import config file

The config file supports two data types. We provide two reference templates for each type: full and mini.
The config file supports `yaml` data type. We provide two reference templates for it: full and mini.

The full version of the configuration file contains all configurable fields, and additional fields will be automatically ignored.

The mini version of the configuration file is a simplified version of the full configuration file, retaining the same functionality. It shows the essential parts of the configuration information.

For the full configuration file, if all fields can be set to their default values, you can simplify it to the mini version. However, it cannot be further reduced beyond the mini version.


In the yaml config files, we provide brief comments on the fields, which can be used as a reference
In the full `yaml` config file, we provide brief comments on the fields, which can be used as a reference.

**Example**

Expand Down
138 changes: 0 additions & 138 deletions cli/import.full.yml

This file was deleted.

71 changes: 0 additions & 71 deletions cli/import.mini.yml

This file was deleted.

18 changes: 2 additions & 16 deletions cli/src/graphar_cli/graphar_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,28 +147,14 @@ def check(
)
def import_data(
config_file: str = typer.Option(None, "--config", "-c", help="Path of the GraphAr config file"),
config_type: str = typer.Option(
"yaml",
"--type",
"-t",
help="Type of config file",
show_choices=True,
show_default=True,
),
):
if not Path(config_file).is_file():
logger.error("File not found: %s", config_file)
raise typer.Exit(1)
if config_type == "json":
with Path(config_file).open(encoding="utf-8") as file:
config = json.load(file)
elif config_type == "yaml":

try:
with Path(config_file).open(encoding="utf-8") as file:
config = yaml.safe_load(file)
else:
logger.error("Config type %s not supported", config_type)
raise typer.Exit(1)
try:
import_config = ImportConfig(**config)
validate(import_config)
except Exception as e:
Expand Down

0 comments on commit 4af9117

Please sign in to comment.