Page MenuHomePhabricator

Deprecate DataSite.createNewItemFromPage
Closed, ResolvedPublic

Description

Introduction

ItemPage has a fromPage classmethod already which lazy loads the wikibase contents when needed. DataSite.createNewItemFromPage can be dropped. The deprecation process needs a deprecation warning first that bot owners can replace the method usage. A FutureWarning will Always be shown which means the method will be removed completely with overnext release.

What to do:

  • add a deprecated decorator with future_warning parameter and ImagePage.fromPage() for the first (instead) parameter
  • look for a sample using deprecated decorator e.g. here

Important hints

Event Timeline

jayvdb raised the priority of this task from to Needs Triage.
jayvdb updated the task description. (Show Details)
jayvdb subscribed.
Restricted Application added subscribers: Aklapper, Unknown Object (MLST). · View Herald TranscriptMay 9 2015, 4:31 AM

@jayvdb
What do you mean by this? Are you saying remove the whole function? I'm a little confused.

@jayvdb
What do you mean by this? Are you saying remove the whole function? I'm a little confused.

It should be deprecated, once we have a better approach.
People shouldnt been to use DataSite directly; instead we should provide a class method on ItemPage. However this probably needs to wait until T94848 is fixed, as that is a larger problem preventing ItemPage to be used as a container for data not yet serialised with a Wikibase ID.

Hello, I want to work on this issue but seems like the issue mentioned above https://phabricator.wikimedia.org/T94848 is not resolved yet and also inactive so do I still have to wait for this to be solved to proceed on this?

Xqt subscribed.

Does not look like a good-first-task. I don’t know what should be done with this task and what should be an alternate way of that method to be deprecated. Probably to be declined. Or wait until the description of this task shows the needed steps.

createNewItemFromPage fails anyway whereas ItemPage.fromPage works due to its lazyload

>>> item1 = repo.createNewItemFromPage(page)
WARNING: C:\pwb\GIT\core\pywikibot\tools\__init__.py:1475: UserWarning: Site wikipedia:no instantiated using different code "nb"
  return obj(*__args, **__kw)

Sleeping for 12.6 seconds, 2021-03-24 10:34:03
WARNING: API error no-external-page: The external client site "vecwiki" did not provide page information for page "Idràułega".
Traceback (most recent call last):
  File "<pyshell#21>", line 1, in <module>
    item1 = repo.createNewItemFromPage(page)
  File "C:\pwb\GIT\core\pywikibot\site\_decorators.py", line 93, in callee
    return fn(self, *args, **kwargs)
  File "C:\pwb\GIT\core\pywikibot\site\_datasite.py", line 745, in createNewItemFromPage
    result = self.editEntity({}, data, bot=bot, **kwargs)
  File "C:\pwb\GIT\core\pywikibot\tools\__init__.py", line 1475, in wrapper
    return obj(*__args, **__kw)
  File "C:\pwb\GIT\core\pywikibot\site\_decorators.py", line 93, in callee
    return fn(self, *args, **kwargs)
  File "C:\pwb\GIT\core\pywikibot\site\_datasite.py", line 344, in editEntity
    return req.submit()
  File "C:\pwb\GIT\core\pywikibot\data\api.py", line 1922, in submit
    raise APIError(**result['error'])
pywikibot.data.api.APIError: no-external-page: The external client site "vecwiki" did not provide page information for page "Idràułega".
[messages: [{'name': 'wikibase-api-no-external-page', 'parameters': ['vecwiki', 'Idràułega'], 'html': {'*': 'Die externe Website „vecwiki“ hat keine Informationen zur Seite „Idràułega“ bereitgestellt.'}}];
 help: See https://www.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt; for notice of API deprecations and breaking changes.]
Xqt updated the task description. (Show Details)
Xqt updated the task description. (Show Details)

@pavit23: You can work on it now.

@Xqt Thank You so much. I will start on it.

Change 674706 had a related patch set uploaded (by Pavit Kaur; author: Pavit Kaur):
[pywikibot/core@master] Deprecate DataSite.createNewItemFromPage

https://gerrit.wikimedia.org/r/674706

Xqt claimed this task.

@pavit23: Thanks a lot.

Change 674706 merged by jenkins-bot:
[pywikibot/core@master] Deprecate DataSite.createNewItemFromPage

https://gerrit.wikimedia.org/r/674706

@Xqt Thanks for guiding and helping me through the process.

Change 697065 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [cleanup] Remove deprecated createNewItemFromPage

https://gerrit.wikimedia.org/r/697065

Change 697065 merged by jenkins-bot:

[pywikibot/core@master] [cleanup] Remove deprecated createNewItemFromPage

https://gerrit.wikimedia.org/r/697065