Skip to content

Commit

Permalink
Added CLI tools documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolea Plesco committed Apr 25, 2022
1 parent bd22467 commit 58b5831
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 6 deletions.
156 changes: 156 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,164 @@ If you contribute to this project please refer to the following project document
* [Meaningfy google Drive of the project (restricted)](https://drive.google.com/drive/folders/1wfWYDAtcaJrYTuB14VzTixr1mJUkCHYl?usp=sharing)

## Installation
### Installation of ted-sws package within external projects using terminal
#### 1. Using the package manager pip
1. Go to the root folder of the project
2. Use the package manager pip to install ted-sws package
```bash
pip install git+https://github.com/meaningfy-ws/ted-sws@main#egg=ted-sws
```
#### 2. Using the Makefile target
1. Go to the root folder of the project
2. Add ted-sws package "git+https://github.com/meaningfy-ws/ted-sws@main#egg=ted-sws" to the "requirements.txt" file
3. Add "setup" target to the Makefile
```bash
setup: install
# Additional post-installation tasks/commands

install:
@ pip install --upgrade pip
# To make a full ted-sws package installation, including all its dependencies:
@ pip install --upgrade --force-reinstall -r requirements.txt
# To upgrade only ted-sws package (faster), without upgrading all the dependencies use the line below
# (this command should be used only after a full installation, instead of the full installtion command):
# @ pip install --upgrade --force-reinstall --no-deps -r requirements.txt
```
4. Run:
```bash
make setup
```

## Usage
### CLI tools (commands/console-scripts) for notice mapping suite manipulation

#### normalisation_resource_generator
Generates all resources files needed for notice mapping suite transformation.

Use:
```bash
normalisation_resource_generator --help
```
to get the Usage Help:
```bash
Usage: normalisation_resource_generator [OPTIONS]

Options:
--queries-folder-path TEXT
--output-folder-path TEXT
--help Show this message and exit.
```

#### metadata_generator
Generates metadata.json file from Conceptual Mappings file data.

Use:
```bash
metadata_generator --help
```
to get the Usage Help:
```bash
Usage: metadata_generator [OPTIONS] [MAPPING_SUITE_ID]

Generates Metadata from Conceptual Mappings.

Options:
-i, --opt-conceptual-mappings-file TEXT Use to overwrite INPUT generator
-o, --opt-output-metadata-file TEXT Use to overwrite OUTPUT generator
-m, --opt-mappings-path TEXT
--help Show this message and exit.
```

#### yarrrml2rml_converter
Converts YARRRML data to RML data.

Use:
```bash
yarrrml2rml_converter --help
```
to get the Usage Help:
```bash
Usage: yarrrml2rml_converter [OPTIONS] [MAPPING_SUITE_ID] [RML_OUTPUT_FILE_NAME]

Converts YARRRML to RML. Skip RML_OUTPUT_FILE_NAME to use the default name.

Options:
-i, --opt-yarrrml-input-file TEXT Use to overwrite INPUT generator
-o, --opt-rml-output-file TEXT Use to overwrite OUTPUT generator
-m, --opt-mappings-path TEXT
--help Show this message and exit.
```

#### sparql_generator
Generates SPARQL queries from Conceptual Mappings file data.

Use:
```bash
sparql_generator --help
```
to get the Usage Help:
```bash
Usage: sparql_generator [OPTIONS] [MAPPING_SUITE_ID]

Generates SPARQL queries from Conceptual Mappings.

Options:
-i, --opt-conceptual-mappings-file TEXT Use to overwrite INPUT generator
-o, --opt-output-sparql-queries-folder TEXT Use to overwrite OUTPUT generator
-rq-name, --opt-rq-name TEXT
-m, --opt-mappings-path TEXT
--help Show this message and exit.
```

#### mapping_suite_processor
Processes Mapping Suite (identified by mapping-suite-id).

Successively runs the following commands:
```bash
metadata_generator
yarrrml2rml_converter
sparql_generator
```

Use:
```bash
mapping_suite_processor --help
```
to get the Usage Help:
```bash
Usage: mapping_suite_processor [OPTIONS] MAPPING_SUITE_ID

Processes Mapping Suite (identified by mapping-suite-id).

Options:
-m, --opt-mappings-path TEXT
--help Show this message and exit.
```

#### transformer
Transforms the Test Mapping Suites.

Use:
```bash
transformer --help
```
to get the Usage Help:
```bash
Usage: transformer [OPTIONS] [MAPPING_SUITE_ID] [SERIALIZATION_FORMAT]

Transforms the Test Mapping Suites (identified by mapping-suite-id). If no
mapping-suite-id is provided, all mapping suites from mappings directory
will be processed.

Options:
--opt-mapping-suite-id TEXT MappingSuite ID to be processed (leave empty
to process all Mapping Suites).
--opt-serialization-format TEXT Serialization format (turtle (default),
nquads, trig, trix, jsonld, hdt).
--opt-mappings-path TEXT
--opt-output-path TEXT
--help Show this message and exit.
```

## Contributions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ def run_cmd(self):
self.log("Running " + LOG_INFO_TEXT.format(f"MappingSuite[{self.mapping_suite_id}]") + " processing ... ")
self.log(LOG_WARN_TEXT.format("#######"))

cmd_yarrrml2rml_converter.run(
cmd_metadata_generator.run(
mapping_suite_id=self.mapping_suite_id,
opt_mappings_path=self.mappings_path
)

cmd_sparql_generator.run(
cmd_yarrrml2rml_converter.run(
mapping_suite_id=self.mapping_suite_id,
opt_mappings_path=self.mappings_path
)

cmd_metadata_generator.run(
cmd_sparql_generator.run(
mapping_suite_id=self.mapping_suite_id,
opt_mappings_path=self.mappings_path
)
Expand All @@ -74,7 +74,7 @@ def run(mapping_suite_id, opt_mappings_path=DEFAULT_MAPPINGS_PATH):
@click.option('-m', '--opt-mappings-path', default=DEFAULT_MAPPINGS_PATH)
def main(mapping_suite_id, opt_mappings_path):
"""
Process Mapping Suite (identified by mapping-suite-id).
Processes Mapping Suite (identified by mapping-suite-id).
"""
run(mapping_suite_id, opt_mappings_path)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
DEFAULT_MAPPINGS_PATH = 'mappings'
DEFAULT_YARRRML_INPUT_FILE = '{mappings_path}/{mapping_suite_id}/transformation/technical_mappings.yarrrml.yaml'
DEFAULT_RML_OUTPUT_FILE = '{mappings_path}/{mapping_suite_id}/transformation/mappings/{output_file_name}'
DEFAULT_RML_OUTPUT_FILE_NAME = 'mappings.rml.ttl'
DEFAULT_RML_OUTPUT_FILE_NAME = 'output.rml.ttl'
CMD_NAME = "CMD_YARRRML2RML_CONVERTER"

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def __process_output_dir(fake_repository_path, fake_mapping_suite_id):
output_dir_path = fake_repository_path / fake_mapping_suite_id / "transformation" / "mappings"
output_file_path = output_dir_path / "mappings.rml.ttl"
output_file_path = output_dir_path / "output.rml.ttl"
assert os.path.isdir(output_dir_path)
assert os.path.isfile(output_file_path)
os.remove(output_file_path)
Expand Down

0 comments on commit 58b5831

Please sign in to comment.