Skip to content

Commit e8a84af

Browse files
committed
Update dependencies, sync project setup with Apify SDK
1 parent ffa2984 commit e8a84af

File tree

8 files changed

+98
-49
lines changed

8 files changed

+98
-49
lines changed

.github/workflows/release.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,3 @@ jobs:
123123
run: gh release upload ${{ github.ref_name }} dist/*
124124
env:
125125
GH_TOKEN: ${{ github.token }}
126-

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
Changelog
22
=========
33

4-
[1.2.0](../../releases/tag/v1.2.0) - Unreleased
4+
[1.2.0](../../releases/tag/v1.2.0) - 2023-05-23
55

66
### Added
77

88
- added option to change the build, memory limit and timeout when resurrecting a run
99

10+
### Internal changes
11+
12+
- updated dependencies
13+
1014
[1.1.1](../../releases/tag/v1.1.1) - 2023-05-05
1115

1216
### Internal changes

CONTRIBUTING.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Development
2+
3+
## Environment
4+
5+
For local development, it is required to have Python 3.8 installed.
6+
7+
It is recommended to set up a virtual environment while developing this package to isolate your development environment,
8+
however, due to the many varied ways Python can be installed and virtual environments can be set up,
9+
this is left up to the developers to do themselves.
10+
11+
One recommended way is with the built-in `venv` module:
12+
13+
```bash
14+
python3 -m venv .venv
15+
source .venv/bin/activate
16+
```
17+
18+
To improve on the experience, you can use [pyenv](https://github.com/pyenv/pyenv) to have an environment with a pinned Python version,
19+
and [direnv](https://github.com/direnv/direnv) to automatically activate/deactivate the environment when you enter/exit the project folder.
20+
21+
## Dependencies
22+
23+
To install this package and its development dependencies, run `make install-dev`
24+
25+
## Formatting
26+
27+
We use `autopep8` and `isort` to automatically format the code to a common format. To run the formatting, just run `make format`.
28+
29+
## Linting, type-checking and unit testing
30+
31+
We use `flake8` for linting, `mypy` for type checking and `pytest` for unit testing. To run these tools, just run `make check-code`.
32+
33+
## Documentation
34+
35+
We use the [Google docstring format](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for documenting the code.
36+
We document every user-facing class or method, and enforce that using the flake8-docstrings library.
37+
38+
The documentation is then rendered from the docstrings in the code, using `pydoc-markdown` and some heavy post-processing,
39+
and from Markdown documents in the `docs` folder in the `docs` branch, and then rendered using Docusaurus and published to GitHub pages.
40+
41+
## Release process
42+
43+
Publishing new versions to [PyPI](https://pypi.org/project/apify-client) happens automatically through GitHub Actions.
44+
45+
On each commit to the `master` branch, a new beta release is published, taking the version number from `pyproject.toml`
46+
and automatically incrementing the beta version suffix by 1 from the last beta release published to PyPI.
47+
48+
A stable version is published when a new release is created using GitHub Releases, again taking the version number from `pyproject.toml`.
49+
The built package assets are automatically uploaded to the GitHub release.
50+
51+
If there is already a stable version with the same version number as in `pyproject.toml` published to PyPI, the publish process fails,
52+
so don't forget to update the version number before releasing a new version.
53+
The release process also fails when the released version is not described in `CHANGELOG.md`,
54+
so don't forget to describe the changes in the new version there.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: clean install-dev lint unit-tests integration-tests type-check check-code format docs check-docs check-async-docstrings fix-async-docstrings check-changelog-entry
1+
.PHONY: clean install-dev build publish twine-check lint unit-tests integration-tests type-check check-code format docs check-docs check-async-docstrings fix-async-docstrings check-changelog-entry
22

33
# This is default for local testing, but GitHub workflows override it to a higher value in CI
44
INTEGRATION_TESTS_CONCURRENCY = 1

README.md

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,56 +17,47 @@ To do that, simply run `pip install apify-client` in your terminal.
1717

1818
For usage instructions, check the documentation on [Apify Docs](https://docs.apify.com/api/client/python/) or in [`docs/docs.md`](docs/docs.md).
1919

20-
## Development
20+
## Quick Start
2121

22-
### Environment
22+
```python
23+
from apify_client import ApifyClient
2324

24-
For local development, it is required to have Python 3.8 installed.
25+
apify_client = ApifyClient('MY-APIFY-TOKEN')
2526

26-
It is recommended to set up a virtual environment while developing this package to isolate your development environment,
27-
however, due to the many varied ways Python can be installed and virtual environments can be set up,
28-
this is left up to the developers to do themselves.
27+
# Start an actor and wait for it to finish
28+
actor_call = apify_client.actor('john-doe/my-cool-actor').call()
2929

30-
One recommended way is with the built-in `venv` module:
31-
32-
```bash
33-
python3 -m venv .venv
34-
source .venv/bin/activate
30+
# Fetch results from the actor's default dataset
31+
dataset_items = apify_client.dataset(actor_call['defaultDatasetId']).list_items().items
3532
```
3633

37-
To improve on the experience, you can use [pyenv](https://github.com/pyenv/pyenv) to have an environment with a pinned Python version,
38-
and [direnv](https://github.com/direnv/direnv) to automatically activate/deactivate the environment when you enter/exit the project folder.
39-
40-
### Dependencies
41-
42-
To install this package and its development dependencies, run `make install-dev`
43-
44-
### Formatting
45-
46-
We use `autopep8` and `isort` to automatically format the code to a common format. To run the formatting, just run `make format`.
47-
48-
### Linting, type-checking and unit testing
34+
## Features
4935

50-
We use `flake8` for linting, `mypy` for type checking and `pytest` for unit testing. To run these tools, just run `make check-code`.
36+
Besides greatly simplifying the process of querying the Apify API, the client provides other useful features.
5137

52-
### Documentation
38+
### Automatic parsing and error handling
5339

54-
We use the [Google docstring format](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for documenting the code.
55-
We document every user-facing class or method, and enforce that using the flake8-docstrings library.
40+
Based on the endpoint, the client automatically extracts the relevant data and returns it in the
41+
expected format. Date strings are automatically converted to `datetime.datetime` objects. For exceptions,
42+
we throw an `ApifyApiError`, which wraps the plain JSON errors returned by API and enriches
43+
them with other context for easier debugging.
5644

57-
The documentation is then rendered from the docstrings in the code using Sphinx and some heavy post-processing and saved as `docs/docs.md`.
58-
To generate the documentation, just run `make docs`.
45+
### Retries with exponential backoff
5946

60-
### Release process
47+
Network communication sometimes fails. The client will automatically retry requests that
48+
failed due to a network error, an internal error of the Apify API (HTTP 500+) or rate limit error (HTTP 429).
49+
By default, it will retry up to 8 times. First retry will be attempted after ~500ms, second after ~1000ms
50+
and so on. You can configure those parameters using the `max_retries` and `min_delay_between_retries_millis`
51+
options of the `ApifyClient` constructor.
6152

62-
Publishing new versions to [PyPI](https://pypi.org/project/apify-client) happens automatically through GitHub Actions.
53+
### Support for asynchronous usage
6354

64-
On each commit to the `master` branch, a new beta release is published, taking the version number from `pyproject.toml`
65-
and automatically incrementing the beta version suffix by 1 from the last beta release published to PyPI.
55+
Starting with version 1.0.0, the package offers an asynchronous version of the client, [`ApifyClientAsync`](https://docs.apify.com/api/client/python),
56+
which allows you to work with the Apify API in an asynchronous way, using the standard `async`/`await` syntax.
6657

67-
A stable version is published when a new release is created using GitHub Releases, again taking the version number from `pyproject.toml`. The built package assets are automatically uploaded to the GitHub release.
58+
### Convenience functions and options
6859

69-
If there is already a stable version with the same version number as in `pyproject.toml` published to PyPI, the publish process fails,
70-
so don't forget to update the version number before releasing a new version.
71-
The release process also fails when the released version is not described in `CHANGELOG.md`,
72-
so don't forget to describe the changes in the new version there.
60+
Some actions can't be performed by the API itself, such as indefinite waiting for an actor run to finish
61+
(because of network timeouts). The client provides convenient `call()` and `wait_for_finish()` functions that do that.
62+
Key-value store records can be retrieved as objects, buffers or streams via the respective options, dataset items
63+
can be fetched as individual objects or serialized data and we plan to add better stream support and async iterators.

pyproject.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ classifiers = [
2323

2424
requires-python = ">=3.8"
2525
dependencies = [
26-
"httpx ~= 0.23.0"
26+
"httpx ~= 0.24.1"
2727
]
2828

2929
[project.optional-dependencies]
3030
dev = [
3131
"autopep8 ~= 2.0.2",
3232
"build ~= 0.10.0",
3333
"flake8 ~= 6.0.0",
34-
"flake8-bugbear ~= 23.3.23",
34+
"flake8-bugbear ~= 23.5.9",
3535
"flake8-commas ~= 2.1.0",
3636
"flake8-comprehensions ~= 3.12.0",
3737
"flake8-datetimez ~= 20.10.0",
@@ -42,15 +42,15 @@ dev = [
4242
"flake8-quotes ~= 3.3.2",
4343
"flake8-unused-arguments ~= 0.0.13",
4444
"isort ~= 5.12.0",
45-
"mypy ~= 1.2.0",
45+
"mypy ~= 1.3.0",
4646
"pep8-naming ~= 0.13.3",
47-
"pre-commit ~= 3.3.1",
47+
"pre-commit ~= 3.3.2",
4848
"pytest ~= 7.3.1",
4949
"pytest-asyncio ~= 0.21.0",
5050
"pytest-only ~= 2.0.0",
5151
"pytest-randomly ~= 3.12.0",
5252
"pytest-timeout ~= 2.1.0",
53-
"pytest-xdist ~= 3.2.1",
53+
"pytest-xdist ~= 3.3.1",
5454
"redbaron ~= 0.9.2",
5555
"sphinx ~= 6.1.3",
5656
"sphinx-autodoc-typehints ~= 1.22",
@@ -63,6 +63,7 @@ dev = [
6363
"Documentation" = "https://docs.apify.com/api/client/python/"
6464
"Source" = "https://github.com/apify/apify-client-python"
6565
"Issue tracker" = "https://github.com/apify/apify-client-python/issues"
66+
"Changelog" = "https://github.com/apify/apify-client-python/blob/master/CHANGELOG.md"
6667
"Apify Homepage" = "https://apify.com"
6768

6869
[build-system]

scripts/check_version_in_changelog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
if not CHANGELOG_PATH.is_file():
1414
raise RuntimeError('Unable to find CHANGELOG.md file')
1515

16-
with open(CHANGELOG_PATH) as changelog_file:
16+
with open(CHANGELOG_PATH, encoding='utf-8') as changelog_file:
1717
for line in changelog_file:
1818
# The heading for the changelog entry for the given version can start with either the version number, or the version number in a link
1919
if re.match(fr'\[?{current_package_version}([\] ]|$)', line):

scripts/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Load the current version number from pyproject.toml
1010
# It is on a line in the format `version = "1.2.3"`
1111
def get_current_package_version() -> str:
12-
with open(PYPROJECT_TOML_FILE_PATH, 'r') as pyproject_toml_file:
12+
with open(PYPROJECT_TOML_FILE_PATH, 'r', encoding='utf-8') as pyproject_toml_file:
1313
for line in pyproject_toml_file:
1414
if line.startswith('version = '):
1515
delim = '"' if '"' in line else "'"
@@ -22,7 +22,7 @@ def get_current_package_version() -> str:
2222
# Write the given version number from pyproject.toml
2323
# It replaces the version number on the line with the format `version = "1.2.3"`
2424
def set_current_package_version(version: str) -> None:
25-
with open(PYPROJECT_TOML_FILE_PATH, 'r+') as pyproject_toml_file:
25+
with open(PYPROJECT_TOML_FILE_PATH, 'r+', encoding='utf-8') as pyproject_toml_file:
2626
updated_pyproject_toml_file_lines = []
2727
version_string_found = False
2828
for line in pyproject_toml_file:

0 commit comments

Comments
 (0)