You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "paul-rogers (via GitHub)" <gi...@apache.org> on 2023/03/15 19:12:21 UTC

[GitHub] [druid] paul-rogers commented on a diff in pull request #13938: pip install for Python Druid API

paul-rogers commented on code in PR #13938:
URL: https://github.com/apache/druid/pull/13938#discussion_r1137610383


##########
examples/quickstart/jupyter-notebooks/README.md:
##########
@@ -65,6 +65,13 @@ Make sure you meet the following requirements before starting the Jupyter-based
     jupyter notebook --port 3001
     ```
 
+- The Python API client for Druid. From the Druid repo in `examples/quickstart/jupyter-notebooks/druidapi`
+  install `druidapi` with the following command:
+
+  ```bash
+  pip install .

Review Comment:
   What directory must I be in? Should I do this first?
   
   ```bash
   cd $DRUID_DEV/examples/quickstart/jupyter-notebooks/druidapi
   ```



##########
examples/quickstart/jupyter-notebooks/README.md:
##########
@@ -1,6 +1,6 @@
 # Jupyter Notebook tutorials for Druid
 
-If you are reading this in Jupyter, switch over to the [- START HERE -](- START HERE -.ipynb]
+If you are reading this in Jupyter, switch over to the [- START HERE -](-START%20HERE-.ipynb)

Review Comment:
   Awkward. If the MD tool doesn't handle spaces in names, let's just rename the notebook to `-START-HERE.ipynb`. We could also use '0' as the leading character: anything that sorts before letters.



##########
examples/quickstart/jupyter-notebooks/druidapi/druidapi/__init__.py:
##########
@@ -13,14 +13,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from .druid import DruidClient
+from druidapi.druid import DruidClient
 
 def jupyter_client(endpoint) -> DruidClient:
     '''
     Create a Druid client configured to display results as HTML withing a Jupyter notebook.
     Waits for the cluster to become ready to avoid intermitent problems when using Druid.
     '''
-    from .html import HtmlDisplayClient
+    from .html_table import HtmlDisplayClient

Review Comment:
   Didn't I move all the display stuff into the `html.py` file as one of my last commits?



##########
examples/quickstart/jupyter-notebooks/druidapi/README.md:
##########
@@ -36,21 +39,25 @@ At present, the best way to use `druidapi` is to clone the Druid repo itself:
 git clone git@github.com:apache/druid.git
 ```
 
-`druidapi` is located in `examples/quickstart/jupyter-notebooks/druidapi/`
+`druidapi` is located in `examples/quickstart/jupyter-notebooks/druidapi/`.
+From this directory, install the package and its dependencies with pip using the following command:
 
-Eventually we would like to create a Python package that can be installed with `pip`. Contributions
-in that area are welcome.
+```
+pip install .
+```
 
-Dependencies are listed in `requirements.txt`.
+Verify your installation by checking that the following commands run in Python without error:
 
-`druidapi` works against any version of Druid. Operations that exploit newer features obviously work
-only against versions of Druid that support those features.
+```python
+import druidapi
+druid = druidapi.jupyter_client('http://localhost:8888')

Review Comment:
   Only the `import` is needed, which will fail if `druidapi` is not on the Python path.



##########
examples/quickstart/jupyter-notebooks/druidapi/README.md:
##########
@@ -36,21 +39,25 @@ At present, the best way to use `druidapi` is to clone the Druid repo itself:
 git clone git@github.com:apache/druid.git
 ```
 
-`druidapi` is located in `examples/quickstart/jupyter-notebooks/druidapi/`
+`druidapi` is located in `examples/quickstart/jupyter-notebooks/druidapi/`.
+From this directory, install the package and its dependencies with pip using the following command:
 
-Eventually we would like to create a Python package that can be installed with `pip`. Contributions
-in that area are welcome.
+```
+pip install .
+```

Review Comment:
   Same note as above.



##########
examples/quickstart/jupyter-notebooks/druidapi/druidapi/__init__.py:
##########
@@ -13,14 +13,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from .druid import DruidClient
+from druidapi.druid import DruidClient

Review Comment:
   These changes are not needed. In Python, '.' means relative to the present module. This allows us to, say, install `druidapi` twice: `druidapi` and `druidApiOld` and have both work.



##########
examples/quickstart/jupyter-notebooks/druidapi/README.md:
##########
@@ -36,21 +39,25 @@ At present, the best way to use `druidapi` is to clone the Druid repo itself:
 git clone git@github.com:apache/druid.git
 ```
 
-`druidapi` is located in `examples/quickstart/jupyter-notebooks/druidapi/`
+`druidapi` is located in `examples/quickstart/jupyter-notebooks/druidapi/`.
+From this directory, install the package and its dependencies with pip using the following command:
 
-Eventually we would like to create a Python package that can be installed with `pip`. Contributions
-in that area are welcome.
+```
+pip install .
+```
 
-Dependencies are listed in `requirements.txt`.
+Verify your installation by checking that the following commands run in Python without error:
 
-`druidapi` works against any version of Druid. Operations that exploit newer features obviously work
-only against versions of Druid that support those features.
+```python
+import druidapi
+druid = druidapi.jupyter_client('http://localhost:8888')
+```
 
-## Getting Started
+## Getting started
 
 To use `druidapi`, first import the library, then connect to your cluster by providing the URL to your Router instance. The way that is done differs a bit between consumers.
 
-### From a Tutorial Jupyter Notebook
+### From a tutorial Jupyter Notebook

Review Comment:
   Always odd that we don't use title case in titles... Is Notebook a proper noun here? Or, should this be:
   
   > From a tutorial Jupyter notebook



##########
examples/quickstart/jupyter-notebooks/druidapi/druidapi/datasource.py:
##########
@@ -32,28 +32,28 @@ class DatasourceClient:
 
     See https://druid.apache.org/docs/latest/operations/api-reference.html#datasources
     '''
-    
+

Review Comment:
   I gotta find the trick in VS Code that drops trailing spaces automatically...



##########
examples/quickstart/jupyter-notebooks/druidapi/README.md:
##########
@@ -36,21 +39,25 @@ At present, the best way to use `druidapi` is to clone the Druid repo itself:
 git clone git@github.com:apache/druid.git
 ```
 
-`druidapi` is located in `examples/quickstart/jupyter-notebooks/druidapi/`
+`druidapi` is located in `examples/quickstart/jupyter-notebooks/druidapi/`.
+From this directory, install the package and its dependencies with pip using the following command:

Review Comment:
   Took me a moment to realize you had introduced another directory level. That is helpful: there is not a place to put the test code that I currently have sitting off to the side. Would be good to mention this structure to make it obvious that there there are two `druidapi` directories here.



##########
examples/quickstart/jupyter-notebooks/druidapi/setup.py:
##########
@@ -0,0 +1,37 @@
+# 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 setuptools import setup, find_packages
+
+setup(
+    name='druidapi',
+    version='0.1.0',
+    description='Python API client for Apache Druid',
+    url='https://github.com/apache/druid/tree/master/examples/quickstart/jupyter-notebooks/druidapi',
+    author='Paul Rogers',

Review Comment:
   Maybe change this to "Apache Druid project".



-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org