Skip to content

feat: add Actor task publication endpoints - #985

Open
apify-service-account wants to merge 4 commits into
masterfrom
update-models-docs-pr-2840
Open

feat: add Actor task publication endpoints#985
apify-service-account wants to merge 4 commits into
masterfrom
update-models-docs-pr-2840

Conversation

@apify-service-account

Copy link
Copy Markdown
Contributor
  • Updates the auto-generated Pydantic models and TypedDicts based on the proposed OpenAPI specification changes.
  • Based on apify-docs PR #2840.

@apify-service-account apify-service-account added the t-tooling Issues with this label are in the ownership of the tooling team. label Aug 2, 2026
@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.87179% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.75%. Comparing base (a6ca0cb) to head (c7a2748).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
src/apify_client/_typeddicts.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #985      +/-   ##
==========================================
+ Coverage   94.71%   94.75%   +0.03%     
==========================================
  Files          58       58              
  Lines        5337     5374      +37     
==========================================
+ Hits         5055     5092      +37     
  Misses        282      282              
Flag Coverage Δ
integration 92.03% <84.61%> (-0.16%) ⬇️
unit 85.02% <94.87%> (+0.55%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Janjiran Janjiran changed the title TODO feat: add Actor task publication endpoints Aug 3, 2026

@vdusek vdusek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Let's merge this once the PRs in apify-core and apify-docs are merged.

@vdusek
vdusek marked this pull request as draft August 3, 2026 14:40
@Janjiran
Janjiran marked this pull request as ready for review August 10, 2026 14:21
@Janjiran
Janjiran requested a review from vdusek August 10, 2026 14:21
@Janjiran Janjiran added this to the 146th sprint - Growth team milestone Aug 10, 2026
@vdusek

vdusek commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Please resolve the failing CI

Janjiran and others added 2 commits August 10, 2026 16:59
The models committed earlier came from a superseded revision of the spec
PR that used dedicated publish/unpublish endpoints. The current revision
puts `isPublic` on the update request instead, which is what the client
code and tests were written against. Also merges master and syncs the
async create docstring.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y6GXQXFZK4XoGwNgXHkk1n

@vdusek vdusek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things, mostly minor test and docs-related stuff.

Marking this as "request changes" since it should be merged after the upstream PR. Also, we probably want to release one more patch version of the client before the next minor release.



@docs_group('Models')
class TaskPublicConfig(BaseModel):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These models come from a spec that is not merged and deployed - Let's wait for the merge of apify/apify-docs#2840.

Comment on lines +19 to +28
_TASK_RESPONSE = {
'data': {
'id': _MOCKED_TASK_ID,
'userId': 'test_user_id',
'actId': 'test_actor_id',
'name': 'test-task',
'createdAt': '2026-08-01T10:00:00.000Z',
'modifiedAt': '2026-08-01T10:00:00.000Z',
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the response half of the feature has no coverage. This fixture carries no isPublic and no publicConfig, and none of the 12 tests looks at the returned Task - every assertion inspects the captured request body. So Task.is_public, Task.public_config and TaskPublicConfig deserialization (including published_at: AwareDatetime) ship unexercised, even though publish()'s whole contract is "returns the published task". Adding 'isPublic': True and a publicConfig block here, then asserting on the returned object, costs two lines.

Comment on lines +30 to +32
# Aliased at module scope so that `list` resolves to the builtin - inside the client classes below,
# a bare `list[str]` annotation would resolve to their own `list` method instead.
InputSchemaFields = list[str]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we rather resolve this shadowing problem in the same way as in the rest of the code base (e.g. actor_version_collection.py:86,89,192,195) via an inline # ty: ignore[invalid-type-form] on a bare list[str].

_client(httpserver).task(_MOCKED_TASK_ID).unpublish()

assert len(captured) == 1
# `False` must survive rather than being dropped as falsy - it is what unpublishes the task.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: nothing in the payload path drops falsy values - model_dump(..., exclude_none=True) (task.py:168) drops only None, and _clean_json_payload (_resource_client.py:151-181) drops only None and empty dicts. The invariant is worth stating, but state the real one.

Suggested change
# `False` must survive rather than being dropped as falsy - it is what unpublishes the task.
# `False` must survive `exclude_none` - it is what unpublishes the task.

assert len(captured) == 1
body = _body_of(captured[0])
assert body['publicConfig'] == {'seoTitle': 'Scrape a website'}
# Publication is never part of a create - it only happens through the update.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this comment restates the assert directly below it - worth dropping.

"""Create a new task.

The `public_config_*` arguments set the public display configuration of the task's landing page, which
requires write access to the task's Actor and the Task itself. Use `TaskClient.publish` for publishing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "Task" is capitalized as if it were an Apify proper noun - only "Actor" is. The same sentence already uses lowercase "task's".

Suggested change
requires write access to the task's Actor and the Task itself. Use `TaskClient.publish` for publishing.
requires write access to the task's Actor and the task itself. Use `TaskClient.publish` for publishing.

"""Create a new task.

The `public_config_*` arguments set the public display configuration of the task's landing page, which
requires write access to the task's Actor and the Task itself. Use `TaskClientAsync.publish` for publishing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: same capitalization as in the sync twin - only "Actor" is an Apify proper noun.

Suggested change
requires write access to the task's Actor and the Task itself. Use `TaskClientAsync.publish` for publishing.
requires write access to the task's Actor and the task itself. Use `TaskClientAsync.publish` for publishing.

return ApifyClientAsync(token='test_token', api_url=httpserver.url_for('/').removesuffix('/'))


def test_publish_sets_is_public_true(httpserver: HTTPServer) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: only test_update_sends_only_the_requested_fields has a docstring, 1 of 12. A one-line docstring per test is the convention worth following here. (The one that does exist is a good one and earns its four lines.)

}


def test_update_can_configure_and_publish_at_once(httpserver: HTTPServer) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this test and test_create_sends_only_the_requested_fields (line 138) have no _async twin, while the other five pairs are mirrored - odd in a repo whose central design rule is sync/async parity.

Comment on lines +43 to +48
def _client(httpserver: HTTPServer) -> ApifyClient:
return ApifyClient(token='test_token', api_url=httpserver.url_for('/').removesuffix('/'))


def _async_client(httpserver: HTTPServer) -> ApifyClientAsync:
return ApifyClientAsync(token='test_token', api_url=httpserver.url_for('/').removesuffix('/'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: test_client_errors.py:87-95 already offers these as sync_client / async_client pytest fixtures. This is the second copy of the token=..., api_url=httpserver.url_for('/').removesuffix('/') incantation; a third would justify moving it to tests/unit/conftest.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants