Skip to content

Commit

Permalink
Removes json2table converter from operator's code
Browse files Browse the repository at this point in the history
  • Loading branch information
mrDzurb committed Sep 14, 2023
1 parent 64d6f4d commit 98b04b9
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 116 deletions.
6 changes: 0 additions & 6 deletions ads/opctl/operator/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
)
from .common.utils import (
_build_image,
_convert_schema_to_html,
_load_yaml_from_uri,
_operator_info_list,
)
Expand Down Expand Up @@ -290,11 +289,6 @@ def init(
with fsspec.open(os.path.join(output, f"{name}.yaml"), mode="w") as f:
f.write(operator_specification_template)

# save operator schema in HTML format
module_schema = _load_yaml_from_uri(os.path.join(operator_path, "schema.yaml"))
with fsspec.open(os.path.join(output, "schema.html"), mode="w") as f:
f.write(_convert_schema_to_html(name, module_schema))

# copy README and original schema files into a destination folder
for src_file in ("README.md", "schema.yaml", "environment.yaml"):
ads_common_utils.copy_file(
Expand Down
109 changes: 2 additions & 107 deletions ads/opctl/operator/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import fsspec
import yaml
from cerberus import Validator
from json2table import convert
from yaml import SafeLoader

from ads.opctl import logger
Expand Down Expand Up @@ -350,7 +349,7 @@ def _extant_file(x: str):


def _parse_input_args(raw_args) -> Tuple:
"""Parses operator inout arguments."""
"""Parses operator input arguments."""
parser = argparse.ArgumentParser()
parser.add_argument(
"-f",
Expand Down Expand Up @@ -401,110 +400,6 @@ def _load_multi_document_yaml_from_uri(uri: str, **kwargs) -> Dict:


def _load_yaml_from_uri(uri: str, **kwargs) -> str:
"""Loads YAML from the URI path. Can be OS path."""
"""Loads YAML from the URI path. Can be Object Storage path."""
with fsspec.open(uri) as f:
return _load_yaml_from_string(str(f.read(), "UTF-8"), **kwargs)


def _convert_schema_to_html(module_name: str, module_schema: str) -> str:
"""Converts operator YAML schema to HTML."""
t = Template(
"""
<style type="text/css">
table {
background: #fff;
font-family: monospace;
font-size: 1.0rem;
}
table,
thead,
tbody,
tfoot,
tr,
td,
th {
margin: auto;
border: 1px solid #ececec;
padding: 0.5rem;
}
table {
display: table;
width: 50%;
}
tr {
display: table-row;
}
thead {
display: table-header-group
}
tbody {
display: table-row-group
}
tfoot {
display: table-footer-group
}
col {
display: table-column
}
colgroup {
display: table-column-group
}
td,
th {
display: table-cell;
width: 50%;
}
caption {
display: table-caption
}
table,
thead,
tbody,
tfoot,
tr,
td,
th {
margin: auto;
padding: 0.5rem;
}
table {
background: #fff;
margin: auto;
border: none;
padding: 0;
margin-bottom: 2rem;
}
th {
text-align: right;
font-weight: 700;
border: 1px solid #ececec;
}
</style>
<h1>Operator: $module_name</h1>
$table
"""
)

return t.substitute(
module_name=module_name,
table=convert(
OperatorValidator(module_schema, allow_unknown=True).schema.schema,
build_direction="LEFT_TO_RIGHT",
),
)
1 change: 0 additions & 1 deletion ads/opctl/operator/lowcode/forecast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ To run forecasting locally, create and activate a new conda environment (`ads-fo
- statsmodels
- datapane
- cerberus
- json2table
- sktime
- optuna==2.9.0
- oracle-automlx==23.2.3
Expand Down
1 change: 0 additions & 1 deletion ads/opctl/operator/lowcode/forecast/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies:
- statsmodels
- datapane
- cerberus
- json2table
- sktime
- optuna==2.9.0
- oracle-automlx==23.2.3
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ opctl = [
"nbformat",
"oci-cli",
"rich",
"json2table",
]
optuna = [
"optuna==2.9.0",
Expand Down

0 comments on commit 98b04b9

Please sign in to comment.