Skip to content

Commit

Permalink
Merge branch 'main' into feat/boolean-additional-properties
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Dec 7, 2022
2 parents e4606c7 + 9d6a48a commit e07d900
Show file tree
Hide file tree
Showing 35 changed files with 346 additions and 173 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip==22.3.1
poetry==1.2.2
virtualenv==20.16.7
nox==2022.8.7
virtualenv==20.17.1
nox==2022.11.21
nox-poetry==1.0.2
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-json
- id: check-toml
Expand Down Expand Up @@ -53,7 +53,7 @@ repos:
exclude: (cookiecutter/.*|singer_sdk/helpers/_simpleeval/.*)

- repo: https://github.com/pycqa/flake8
rev: 5.0.4
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -63,7 +63,7 @@ repos:
files: 'singer_sdk/.*'

- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
rev: v3.3.0
hooks:
- id: pyupgrade
args: [--py37-plus]
Expand Down
33 changes: 32 additions & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,43 @@ Supported platform markers are `windows`, `darwin`, and `linux`.
### Snapshot Testing

We use [pytest-snapshot](https://pypi.org/project/pytest-snapshot/) for snapshot testing.
To update snapshots, run:

#### Adding a new snapshot

To add a new snapshot, use the `snapshot` fixture and mark the test with the
`@pytest.mark.snapshot` decorator. The fixture will create a new snapshot file
if one does not already exist. If a snapshot file already exists, the fixture
will compare the snapshot to the actual value and fail the test if they do not
match.

The `tests/snapshots` directory is where snapshot files should be stored and
it's available as the `snapshot_dir` fixture.

```python
@pytest.mark.snapshot
def test_snapshot(snapshot, snapshot_dir):
# Configure the snapshot directory
snapshot.snapshot_dir = snapshot_dir.joinpath("test_snapshot_subdir")

snapshot_name = "test_snapshot"
expected_content = "Hello, World!"
snapshot.assert_match(expected_content, snapshot_name)
```

#### Generating or updating snapshots

To update or generate snapshots, run the nox `update_snapshots` session

```bash
nox -rs update_snapshots
```

or use the `--snapshot-update` flag

```bash
poetry run pytest --snapshot-update -m 'snapshot'
```

This will run all tests with the `snapshot` marker and update any snapshots that have changed.
Commit the updated snapshots to your branch if they are expected to change.

Expand Down
10 changes: 10 additions & 0 deletions docs/_templates/plugin_class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{ fullname }}
{{ "=" * fullname|length }}

.. currentmodule:: {{ module }}

.. autoclass:: {{ name }}
:members:
:show-inheritance:
:inherited-members:
:special-members: __init__
2 changes: 2 additions & 0 deletions docs/classes/singer_sdk.InlineMapper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@

.. autoclass:: InlineMapper
:members:
:show-inheritance:
:inherited-members:
:special-members: __init__
2 changes: 2 additions & 0 deletions docs/classes/singer_sdk.SQLTap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@

.. autoclass:: SQLTap
:members:
:show-inheritance:
:inherited-members:
:special-members: __init__
2 changes: 2 additions & 0 deletions docs/classes/singer_sdk.SQLTarget.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@

.. autoclass:: SQLTarget
:members:
:show-inheritance:
:inherited-members:
:special-members: __init__
2 changes: 2 additions & 0 deletions docs/classes/singer_sdk.Tap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@

.. autoclass:: Tap
:members:
:show-inheritance:
:inherited-members:
:special-members: __init__
2 changes: 2 additions & 0 deletions docs/classes/singer_sdk.Target.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@

.. autoclass:: Target
:members:
:show-inheritance:
:inherited-members:
:special-members: __init__
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
html_theme_options = {"logo_only": True, "analytics_id": "G-84WQMSLGTE"}
html_theme_options = {"logo_only": True, "analytics_id": "GTM-WHJMBX2"}

html_logo = "_static/img/logo.svg"

Expand Down
34 changes: 32 additions & 2 deletions docs/implementation/logging.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,43 @@
# Logging
# [SDK Implementation Details](./index.md) - Logging

Logs are configurable by the environment variables `<PLUGIN_NAME>_LOGLEVEL` (preferred)
## Logging levels

Logging levels are configurable by the environment variables `<PLUGIN_NAME>_LOGLEVEL` (preferred)
or `LOGLEVEL`. Use `LOGLEVEL` when you intend to control the log output for all taps
and targets running within the environment. In contrast, we recommend setting
`<PLUGIN_NAME>_LOGLEVEL` for more granual control of each tap or target individually.

From most verbose to least verbose, the accepted values for logging level are `debug`,
`info`, `warning`, and `error`. Logging level inputs are case-insensitive.

To use different logging levels for different loggers, see the [custom logging configuration](#custom-logging-configuration) section below.

## Default log format

The default log format is `"{asctime:23s} | {levelname:8s} | {name:20s} | {message}"`.

This produces logs that look like this:

```
2022-12-05 19:46:46,744 | INFO | my_tap | Added 'child' as child stream to 'my_stream'
2022-12-05 19:46:46,744 | INFO | my_tap | Beginning incremental sync of 'my_stream'...
2022-12-05 19:46:46,744 | INFO | my_tap | Tap has custom mapper. Using 1 provided map(s).
2022-12-05 19:46:46,745 | INFO | my_tap | Beginning full_table sync of 'child' with context: {'parent_id': 1}...
2022-12-05 19:46:46,745 | INFO | my_tap | Tap has custom mapper. Using 1 provided map(s).
2022-12-05 19:46:46,746 | INFO | singer_sdk.metrics | INFO METRIC: {"metric_type": "timer", "metric": "sync_duration", "value": 0.0005319118499755859, "tags": {"stream": "child", "context": {"parent_id": 1}, "status": "succeeded"}}
2022-12-05 19:46:46,747 | INFO | singer_sdk.metrics | INFO METRIC: {"metric_type": "counter", "metric": "record_count", "value": 3, "tags": {"stream": "child", "context": {"parent_id": 1}}}
2022-12-05 19:46:46,747 | INFO | my_tap | Beginning full_table sync of 'child' with context: {'parent_id': 2}...
2022-12-05 19:46:46,748 | INFO | singer_sdk.metrics | INFO METRIC: {"metric_type": "timer", "metric": "sync_duration", "value": 0.0004410743713378906, "tags": {"stream": "child", "context": {"parent_id": 2}, "status": "succeeded"}}
2022-12-05 19:46:46,748 | INFO | singer_sdk.metrics | INFO METRIC: {"metric_type": "counter", "metric": "record_count", "value": 3, "tags": {"stream": "child", "context": {"parent_id": 2}}}
2022-12-05 19:46:46,749 | INFO | my_tap | Beginning full_table sync of 'child' with context: {'parent_id': 3}...
2022-12-05 19:46:46,749 | INFO | singer_sdk.metrics | INFO METRIC: {"metric_type": "timer", "metric": "sync_duration", "value": 0.0004508495330810547, "tags": {"stream": "child", "context": {"parent_id": 3}, "status": "succeeded"}}
2022-12-05 19:46:46,750 | INFO | singer_sdk.metrics | INFO METRIC: {"metric_type": "counter", "metric": "record_count", "value": 3, "tags": {"stream": "child", "context": {"parent_id": 3}}}
2022-12-05 19:46:46,750 | INFO | singer_sdk.metrics | INFO METRIC: {"metric_type": "timer", "metric": "sync_duration", "value": 0.0052759647369384766, "tags": {"stream": "my_stream", "context": {}, "status": "succeeded"}}
2022-12-05 19:46:46,750 | INFO | singer_sdk.metrics | INFO METRIC: {"metric_type": "counter", "metric": "record_count", "value": 3, "tags": {"stream": "my_stream", "context": {}}}
```

To use a different log format, see the [custom logging configuration](#custom-logging-configuration) section below.

## Custom logging configuration

Users of a tap can configure the SDK logging by setting the `SINGER_SDK_LOG_CONFIG`
Expand Down
2 changes: 1 addition & 1 deletion docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Plugin Classes

.. autosummary::
:toctree: classes
:template: class.rst
:template: plugin_class.rst

Tap
Target
Expand Down
Loading

0 comments on commit e07d900

Please sign in to comment.