Skip to content

Commit

Permalink
Merge branch 'develop' into prototype/snowflake
Browse files Browse the repository at this point in the history
* develop:
  Add more type annotations (#4657)
  CI release flow improvements (#4661)
  Cloud updates in README (#4668)
  Fix moment.js timezone error (#4669)
  • Loading branch information
tconkling committed May 3, 2022
2 parents bda7aea + 27ff5c2 commit d3a61a7
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 62 deletions.
18 changes: 9 additions & 9 deletions .circleci/config.yml
Expand Up @@ -224,19 +224,19 @@ workflows:
- python-min-version: # Oldest supported Python minor version.
filters:
tags:
only: /^(([0-9]+\.){3}dev[0-9]+)|(^([0-9]+\.){2}([0-9]+))/ # 0.56.1.dev20201129 or 1.6.0
only: /^(([0-9]+\.){3}dev[0-9]+)/ # 0.56.1.dev20201129
- python-max-version: # Latest supported Python minor version.
filters:
tags:
only: /^(([0-9]+\.){3}dev[0-9]+)|(^([0-9]+\.){2}([0-9]+))/
only: /^(([0-9]+\.){3}dev[0-9]+)/
- python-prod-deps-smoke-test: # Make sure Streamlit runs without dev dependencies
filters:
tags:
only: /^(([0-9]+\.){3}dev[0-9]+)|(^([0-9]+\.){2}([0-9]+))/
only: /^(([0-9]+\.){3}dev[0-9]+)/
- cypress: # Non flaky Cypress tests
filters:
tags:
only: /^(([0-9]+\.){3}dev[0-9]+)|(^([0-9]+\.){2}([0-9]+))/
only: /^(([0-9]+\.){3}dev[0-9]+)/
- pr-preview: # Make a preview branch for each PR
filters:
tags:
Expand Down Expand Up @@ -268,11 +268,6 @@ workflows:
branches:
only: /^release\/([0-9]+\.){2}([0-9]+)/
- build-deploy-release:
requires:
- python-min-version
- python-max-version
- cypress
- python-prod-deps-smoke-test
filters:
tags:
only: /^([0-9]+\.){2}([0-9]+)/
Expand Down Expand Up @@ -399,6 +394,11 @@ jobs:
exit 1
fi
- run:
name: Checkout head of branch
command: |
git pull origin ${GH_PR_BRANCH} --ff-only
- configure-build-env

- run:
Expand Down
7 changes: 2 additions & 5 deletions README.md
Expand Up @@ -57,12 +57,9 @@ Once you deploy your app, you can embed this badge right into your GitHub readme
- More [demo projects](https://github.com/streamlit/) to inspire you
- And if you would like to contribute, see [instructions here](https://github.com/streamlit/streamlit/wiki/Contributing)

## Streamlit Cloud
## Community Cloud

[Streamlit Cloud](https://streamlit.io/cloud) is our deployment solution for managing, sharing, and collaborating on your Streamlit apps.

- The Teams and Enterprise plans provide secure single-click deploy, authentication, web editing, versioning, and much more for your Streamlit apps. You can sign-up [here](https://share.streamlit.io/signup).
- The Starter plan is the perfect solution if your app is hosted in a public GitHub repo and you’d like anyone in the world to be able to access it. It's completely free to use and you can sign-up [here](https://share.streamlit.io).
With [Community Cloud](https://streamlit.io/cloud) you can deploy, manage, and share your apps with the world, directly from Streamlit — all for free. Sign-up [here](https://share.streamlit.io/signup).

## License

Expand Down
10 changes: 10 additions & 0 deletions frontend/src/lib/Quiver.test.ts
Expand Up @@ -379,6 +379,16 @@ describe("Quiver", () => {
).toEqual("1970-01-01T03:00:00+03:00")
})

test("datetimetz with offset", () => {
expect(
Quiver.format(0, {
pandas_type: "datetimetz",
numpy_type: "datetime64[ns]",
meta: { timezone: "+01:00" },
})
).toEqual("1970-01-01T01:00:00+01:00")
})

test("interval datetime64[ns]", () => {
const mockElement = { data: INTERVAL_DATETIME64 }
const q = new Quiver(mockElement)
Expand Down
18 changes: 14 additions & 4 deletions frontend/src/lib/Quiver.ts
Expand Up @@ -717,9 +717,19 @@ but was expecting \`${JSON.stringify(expectedIndexTypes)}\`.
// datetimetz
if (isDate && typeName === "datetimetz") {
const meta = type?.meta
return moment(x as Date | number)
.tz(meta?.timezone)
.format("YYYY-MM-DDTHH:mm:ssZ")
let datetime = moment(x as Date | number)

if (meta?.timezone) {
if (moment.tz.zone(meta?.timezone)) {
// uses timezone notation
datetime = datetime.tz(meta?.timezone)
} else {
// uses UTC offset notation
datetime = datetime.utcOffset(meta?.timezone)
}
}

return datetime.format("YYYY-MM-DDTHH:mm:ssZ")
}
// datetime, datetime64, datetime64[ns], etc.
if (isDate && typeName?.startsWith("datetime")) {
Expand Down Expand Up @@ -978,7 +988,7 @@ but was expecting \`${JSON.stringify(expectedIndexTypes)}\`.
throw new Error(`
Unsupported operation. \`add_rows()\` does not support Pandas Styler objects.
If you do not need the Styler's styles, try passing the \`.data\` attribute of
If you do not need the Styler's styles, try passing the \`.data\` attribute of
the Styler object instead to concatenate just the underlying dataframe.
For example:
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/__snapshots__/Quiver.test.ts.snap
Expand Up @@ -34,7 +34,7 @@ exports[`Quiver Add rows Special cases throws an error if one of the DataFrames
"
Unsupported operation. \`add_rows()\` does not support Pandas Styler objects.
If you do not need the Styler's styles, try passing the \`.data\` attribute of
If you do not need the Styler's styles, try passing the \`.data\` attribute of
the Styler object instead to concatenate just the underlying dataframe.
For example:
Expand All @@ -48,7 +48,7 @@ exports[`Quiver Add rows Special cases throws an error if one of the DataFrames
"
Unsupported operation. \`add_rows()\` does not support Pandas Styler objects.
If you do not need the Styler's styles, try passing the \`.data\` attribute of
If you do not need the Styler's styles, try passing the \`.data\` attribute of
the Styler object instead to concatenate just the underlying dataframe.
For example:
Expand Down
8 changes: 4 additions & 4 deletions lib/streamlit/__init__.py
Expand Up @@ -206,7 +206,7 @@ def _update_logger():
beta_columns = _main.beta_columns


def set_option(key, value):
def set_option(key: str, value) -> None:
"""Set config option.
Currently, only the following config options can be set within the script itself:
Expand Down Expand Up @@ -372,7 +372,7 @@ def experimental_set_query_params(**query_params):


@_contextlib.contextmanager
def spinner(text="In progress..."):
def spinner(text: str = "In progress..."):
"""Temporarily displays a message while executing a block of code.
Parameters
Expand Down Expand Up @@ -446,7 +446,7 @@ def _transparent_write(*args):
_use_warning_has_been_displayed = False


def _maybe_print_use_warning():
def _maybe_print_use_warning() -> None:
"""Print a warning if Streamlit is imported but not being run with `streamlit run`.
The warning is printed only once.
"""
Expand Down Expand Up @@ -492,7 +492,7 @@ def stop() -> NoReturn:
raise StopException()


def experimental_rerun():
def experimental_rerun() -> NoReturn:
"""Rerun the script immediately.
When `st.experimental_rerun()` is called, the script is halted - no
Expand Down
30 changes: 18 additions & 12 deletions lib/streamlit/elements/alert.py
Expand Up @@ -12,15 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import cast
from typing import cast, TYPE_CHECKING

import streamlit
from streamlit.proto.Alert_pb2 import Alert as AlertProto
from .utils import clean_text

if TYPE_CHECKING:
from streamlit.delta_generator import DeltaGenerator


class AlertMixin:
def error(self, body):
def error(self, body: str) -> "DeltaGenerator":
"""Display error message.
Parameters
Expand All @@ -36,9 +38,10 @@ def error(self, body):
alert_proto = AlertProto()
alert_proto.body = clean_text(body)
alert_proto.format = AlertProto.ERROR
return self.dg._enqueue("alert", alert_proto)
dg = self.dg._enqueue("alert", alert_proto)
return cast("DeltaGenerator", dg)

def warning(self, body):
def warning(self, body: str) -> "DeltaGenerator":
"""Display warning message.
Parameters
Expand All @@ -54,9 +57,10 @@ def warning(self, body):
alert_proto = AlertProto()
alert_proto.body = clean_text(body)
alert_proto.format = AlertProto.WARNING
return self.dg._enqueue("alert", alert_proto)
dg = self.dg._enqueue("alert", alert_proto)
return cast("DeltaGenerator", dg)

def info(self, body):
def info(self, body: str) -> "DeltaGenerator":
"""Display an informational message.
Parameters
Expand All @@ -72,9 +76,10 @@ def info(self, body):
alert_proto = AlertProto()
alert_proto.body = clean_text(body)
alert_proto.format = AlertProto.INFO
return self.dg._enqueue("alert", alert_proto)
dg = self.dg._enqueue("alert", alert_proto)
return cast("DeltaGenerator", dg)

def success(self, body):
def success(self, body: str) -> "DeltaGenerator":
"""Display a success message.
Parameters
Expand All @@ -90,9 +95,10 @@ def success(self, body):
alert_proto = AlertProto()
alert_proto.body = clean_text(body)
alert_proto.format = AlertProto.SUCCESS
return self.dg._enqueue("alert", alert_proto)
dg = self.dg._enqueue("alert", alert_proto)
return cast("DeltaGenerator", dg)

@property
def dg(self) -> "streamlit.delta_generator.DeltaGenerator":
def dg(self) -> "DeltaGenerator":
"""Get our DeltaGenerator."""
return cast("streamlit.delta_generator.DeltaGenerator", self)
return cast("DeltaGenerator", self)
3 changes: 2 additions & 1 deletion lib/streamlit/elements/button.py
Expand Up @@ -17,6 +17,7 @@

from streamlit.type_util import Key, to_key
from typing import cast, Optional, Union, BinaryIO, TextIO
from typing_extensions import Final
from textwrap import dedent

import streamlit
Expand All @@ -34,7 +35,7 @@
from .utils import check_callback_rules, check_session_state_rules


FORM_DOCS_INFO = """
FORM_DOCS_INFO: Final = """
For more information, refer to the
[documentation for forms](https://docs.streamlit.io/library/api-reference/control-flow/st.form).
Expand Down
47 changes: 29 additions & 18 deletions lib/streamlit/elements/markdown.py
Expand Up @@ -12,16 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import cast
from typing import cast, Optional, TYPE_CHECKING, Union

import streamlit
from streamlit import type_util
from streamlit.proto.Markdown_pb2 import Markdown as MarkdownProto
from .utils import clean_text

if TYPE_CHECKING:
import sympy

from streamlit.delta_generator import DeltaGenerator


class MarkdownMixin:
def markdown(self, body, unsafe_allow_html=False):
def markdown(self, body: str, unsafe_allow_html: bool = False) -> "DeltaGenerator":
"""Display string formatted as Markdown.
Parameters
Expand Down Expand Up @@ -72,9 +76,10 @@ def markdown(self, body, unsafe_allow_html=False):
markdown_proto.body = clean_text(body)
markdown_proto.allow_html = unsafe_allow_html

return self.dg._enqueue("markdown", markdown_proto)
dg = self.dg._enqueue("markdown", markdown_proto)
return cast("DeltaGenerator", dg)

def header(self, body, anchor=None):
def header(self, body: str, anchor: Optional[str] = None) -> "DeltaGenerator":
"""Display text in header formatting.
Parameters
Expand All @@ -97,9 +102,10 @@ def header(self, body, anchor=None):
else:
header_proto.body = f'<h2 data-anchor="{anchor}">{clean_text(body)}</h2>'
header_proto.allow_html = True
return self.dg._enqueue("markdown", header_proto)
dg = self.dg._enqueue("markdown", header_proto)
return cast("DeltaGenerator", dg)

def subheader(self, body, anchor=None):
def subheader(self, body: str, anchor: Optional[str] = None) -> "DeltaGenerator":
"""Display text in subheader formatting.
Parameters
Expand All @@ -123,9 +129,10 @@ def subheader(self, body, anchor=None):
subheader_proto.body = f'<h3 data-anchor="{anchor}">{clean_text(body)}</h3>'
subheader_proto.allow_html = True

return self.dg._enqueue("markdown", subheader_proto)
dg = self.dg._enqueue("markdown", subheader_proto)
return cast("DeltaGenerator", dg)

def code(self, body, language="python"):
def code(self, body: str, language: Optional[str] = "python") -> "DeltaGenerator":
"""Display a code block with optional syntax highlighting.
(This is a convenience wrapper around `st.markdown()`)
Expand All @@ -152,9 +159,10 @@ def code(self, body, language="python"):
"body": body,
}
code_proto.body = clean_text(markdown)
return self.dg._enqueue("markdown", code_proto)
dg = self.dg._enqueue("markdown", code_proto)
return cast("DeltaGenerator", dg)

def title(self, body, anchor=None):
def title(self, body: str, anchor: Optional[str] = None) -> "DeltaGenerator":
"""Display text in title formatting.
Each document should have a single `st.title()`, although this is not
Expand All @@ -180,9 +188,10 @@ def title(self, body, anchor=None):
else:
title_proto.body = f'<h1 data-anchor="{anchor}">{clean_text(body)}</h1>'
title_proto.allow_html = True
return self.dg._enqueue("markdown", title_proto)
dg = self.dg._enqueue("markdown", title_proto)
return cast("DeltaGenerator", dg)

def caption(self, body, unsafe_allow_html=False):
def caption(self, body: str, unsafe_allow_html: bool = False) -> "DeltaGenerator":
"""Display text in small font.
This should be used for captions, asides, footnotes, sidenotes, and
Expand Down Expand Up @@ -223,9 +232,10 @@ def caption(self, body, unsafe_allow_html=False):
caption_proto.body = clean_text(body)
caption_proto.allow_html = unsafe_allow_html
caption_proto.is_caption = True
return self.dg._enqueue("markdown", caption_proto)
dg = self.dg._enqueue("markdown", caption_proto)
return cast("DeltaGenerator", dg)

def latex(self, body):
def latex(self, body: Union[str, "sympy.Expr"]) -> "DeltaGenerator":
# This docstring needs to be "raw" because of the backslashes in the
# example below.
r"""Display mathematical expressions formatted as LaTeX.
Expand Down Expand Up @@ -257,9 +267,10 @@ def latex(self, body):

latex_proto = MarkdownProto()
latex_proto.body = "$$\n%s\n$$" % clean_text(body)
return self.dg._enqueue("markdown", latex_proto)
dg = self.dg._enqueue("markdown", latex_proto)
return cast("DeltaGenerator", dg)

@property
def dg(self) -> "streamlit.delta_generator.DeltaGenerator":
def dg(self) -> "DeltaGenerator":
"""Get our DeltaGenerator."""
return cast("streamlit.delta_generator.DeltaGenerator", self)
return cast("DeltaGenerator", self)

0 comments on commit d3a61a7

Please sign in to comment.