Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

updated package naming and created folder for release notes #33

Merged
merged 1 commit into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endpoint such as AWS Elasticsearch.

## Configuration
- A config file is automatically created at `~/.config/odfesql-cli/config` at first launch (for MacOS and Linux).
Check out [clirc](./odfesql_cli/conf/clirc) for details of all available configurations.
Check out [clirc](src/conf/clirc) for details of all available configurations.
- It can be configured and will be auto-loaded next time.

## Features
Expand Down
2 changes: 1 addition & 1 deletion development_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ any endpoint, it uses http://localhost:9200 by default.
### Workflow

1. Update version number
1. Modify the version number in `_init_.py` under `odfesql_cli` package. It will be used by `setup.py` for release.
1. Modify the version number in `_init_.py` under `src` package. It will be used by `setup.py` for release.
2. Create/Update `setup.py` (if needed)
1. For more details refer to https://packaging.python.org/tutorials/packaging-projects/#creating-setup-py
3. Update README.md, Legal and copyright files(if needed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### New Features

This is the first official release of Open Distro Elasticsearch SQL CLI
This is the first official release of Open Distro for Elasticsearch SQL CLI

ODFE SQL CLI is a stand alone Python application and can be launched by a wake word `odfesql`. It serves as a support only for
[Open Distro SQL plugin for Elasticsearch](https://opendistro.github.io/for-elasticsearch-docs/docs/sql/). User must have ODFE SQL
Expand Down
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

_version_re = re.compile(r"__version__\s+=\s+(.*)")

with open("odfesql_cli/__init__.py", "rb") as f:
with open("src/__init__.py", "rb") as f:
version = str(
ast.literal_eval(_version_re.search(f.read().decode("utf-8")).group(1))
)
Expand All @@ -42,24 +42,23 @@

setup(
name="odfesql",
author="Zhongnan",
author_email="zhongnan.su@outlook.com",
author="Zhongnan Su",
author_email="szhongna@amazon.com",
version=version,
license="Apache 2.0",
url="https://opendistro.github.io/for-elasticsearch-docs/",
packages=find_packages(),
package_data={"odfesql_cli": ["conf/clirc", "esliterals/esliterals.json"]},
package_data={"src": ["conf/clirc", "esliterals/esliterals.json"]},
description=description,
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=install_requirements,
entry_points={"console_scripts": ["odfesql=odfesql_cli.main:cli"]},
entry_points={"console_scripts": ["odfesql=src.main:cli"]},
classifiers=[
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: Unix",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions odfesql_cli/config.py → src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ def _write_default_config(source, destination, overwrite=False):
# https://stackoverflow.com/questions/40193112/python-setuptools-distribute-configuration-files-to-os-specific-directories
def get_config(clirc_file=None):
"""
Get config for odfesql_cli.
Get config for odfesql cli.

This config comes from either existing config in the OS, or create a config file in the OS, and write default config
including in the package to it.
"""
from odfesql_cli.conf import __file__ as package_root
from src.conf import __file__ as package_root

package_root = os.path.dirname(package_root)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions odfesql_cli/odfesql_cli.py → src/odfesql_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, clirc_file=None, always_use_pager=False, use_aws_authenticati
self.table_format = config["main"]["table_format"]
self.multiline_continuation_char = config["main"]["multiline_continuation_char"]
self.multi_line = config["main"].as_bool("multi_line")
self.multiline_mode = config["main"].get("multi_line_mode", "odfesql_cli")
self.multiline_mode = config["main"].get("multi_line_mode", "src")
self.null_string = config["main"].get("null_string", "null")
self.style_output = style_factory_output(self.syntax_style, self.cli_style)

Expand Down Expand Up @@ -174,7 +174,7 @@ def _get_literals(self):

:return: a dict that is parsed from esliterals.json
"""
from odfesql_cli.esliterals import __file__ as package_root
from src.esliterals import __file__ as package_root

package_root = os.path.dirname(package_root)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def connection():

@pytest.fixture(scope="function")
def default_config_location():
from odfesql_cli.conf import __file__ as package_root
from src.conf import __file__ as package_root

package_root = os.path.dirname(package_root)
default_config = os.path.join(package_root, "clirc")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import stat
import pytest

from odfesql_cli.config import ensure_dir_exists
from src.config import ensure_dir_exists


class TestConfig:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_esconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from elasticsearch import Elasticsearch, RequestsHttpConnection

from utils import estest, load_data, run, TEST_INDEX_NAME
from odfesql_cli.esconnection import ESConnection
from src.esconnection import ESConnection

INVALID_ENDPOINT = "http://invalid:9200"
OPEN_DISTRO_ENDPOINT = "https://opedistro:9200"
Expand Down Expand Up @@ -59,7 +59,7 @@ def test_query_nonexistent_index(self, connection):
"type": "IndexNotFoundException",
}

with mock.patch("odfesql_cli.esconnection.click.secho") as mock_secho:
with mock.patch("src.esconnection.click.secho") as mock_secho:
run(connection, "select * from non-existed")

mock_secho.assert_called_with(message=str(expected), fg="red")
Expand All @@ -68,7 +68,7 @@ def test_connection_fail(self):
test_executor = ESConnection(endpoint=INVALID_ENDPOINT)
err_message = "Can not connect to endpoint %s" % INVALID_ENDPOINT

with mock.patch("sys.exit") as mock_sys_exit, mock.patch("odfesql_cli.esconnection.click.secho") as mock_secho:
with mock.patch("sys.exit") as mock_sys_exit, mock.patch("src.esconnection.click.secho") as mock_secho:
test_executor.set_connection()

mock_sys_exit.assert_called()
Expand All @@ -83,7 +83,7 @@ def side_effect_set_connection(is_reconnected):
else:
return ConnectionError()

with mock.patch("odfesql_cli.esconnection.click.secho") as mock_secho, mock.patch.object(
with mock.patch("src.esconnection.click.secho") as mock_secho, mock.patch.object(
test_esexecutor, "set_connection"
) as mock_set_connection:
# Assume reconnection success
Expand Down
12 changes: 6 additions & 6 deletions tests/test_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
import pytest
from collections import namedtuple

from odfesql_cli.odfesql_cli import OdfeSqlCli, COLOR_CODE_REGEX
from odfesql_cli.formatter import Formatter
from odfesql_cli.utils import OutputSettings
from src.odfesql_cli import OdfeSqlCli, COLOR_CODE_REGEX
from src.formatter import Formatter
from src.utils import OutputSettings


class TestFormatter:
@pytest.fixture
def pset_pager_mocks(self):
cli = OdfeSqlCli()
with mock.patch("odfesql_cli.main.click.echo") as mock_echo, mock.patch(
"odfesql_cli.main.click.echo_via_pager"
with mock.patch("src.main.click.echo") as mock_echo, mock.patch(
"src.main.click.echo_via_pager"
) as mock_echo_via_pager, mock.patch.object(cli, "prompt_app") as mock_app:
yield cli, mock_echo, mock_echo_via_pager, mock_app

Expand Down Expand Up @@ -120,7 +120,7 @@ def test_format_output_vertical(self):
"age | 24",
]

with mock.patch("odfesql_cli.main.click.secho") as mock_secho, mock.patch("odfesql_cli.main.click.confirm") as mock_confirm:
with mock.patch("src.main.click.secho") as mock_secho, mock.patch("src.main.click.confirm") as mock_confirm:
expanded_results = formatter.format_output(data)

mock_secho.assert_called_with(message="Output longer than terminal width", fg="red")
Expand Down
6 changes: 3 additions & 3 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from click.testing import CliRunner

from utils import estest, load_data, run, get_connection, TEST_INDEX_NAME
from odfesql_cli.main import cli
from odfesql_cli.odfesql_cli import OdfeSqlCli
from src.main import cli
from src.odfesql_cli import OdfeSqlCli

INVALID_ENDPOINT = "http://invalid:9200"
ENDPOINT = "http://localhost:9200"
Expand All @@ -44,7 +44,7 @@ def test_explain(self, connection):
+-----+"""
)

with mock.patch("odfesql_cli.main.click.echo") as mock_echo, mock.patch("odfesql_cli.main.click.secho") as mock_secho:
with mock.patch("src.main.click.echo") as mock_echo, mock.patch("src.main.click.secho") as mock_secho:
runner = CliRunner()

# test -q -e
Expand Down
8 changes: 4 additions & 4 deletions tests/test_odfesql_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
from prompt_toolkit.shortcuts import PromptSession
from prompt_toolkit.input.defaults import create_pipe_input

from odfesql_cli.esbuffer import es_is_multiline
from src.esbuffer import es_is_multiline
from utils import estest, load_data, TEST_INDEX_NAME, ENDPOINT
from odfesql_cli.odfesql_cli import OdfeSqlCli
from odfesql_cli.esconnection import ESConnection
from odfesql_cli.esstyle import style_factory
from src.odfesql_cli import OdfeSqlCli
from src.esconnection import ESConnection
from src.esstyle import style_factory

AUTH = None
QUERY_WITH_CTRL_D = "select * from %s;\r\x04\r" % TEST_INDEX_NAME
Expand Down
6 changes: 3 additions & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import pytest
from elasticsearch import ConnectionError, helpers, ConnectionPool

from odfesql_cli.esconnection import ESConnection
from odfesql_cli.utils import OutputSettings
from odfesql_cli.formatter import Formatter
from src.esconnection import ESConnection
from src.utils import OutputSettings
from src.formatter import Formatter

TEST_INDEX_NAME = "odfesql_cli_test"
ENDPOINT = "http://localhost:9200"
Expand Down