Comments (5)
@robertvazan I realized that this was actually supported by the previous editing API, that is now deprecated.
Beyond returning the revision id, that editing API also returned the new state of the document after editing, which feels like a useful feature too.
I think it would be useful to bring this feature back in the new API. The way I would go about it is change the EntityUpdate
classes so that they do not just hold the base revision id to work from, but also (optionally) the state of the document at that revision id.
I have realized that the Builder classes for EntityUpdate actually let us start from such a document - it just is not stored in the built object so far. So I would store those in the built updates, and then use that in WikibaseDataEditor
to reconstruct the state of the edited document by reunifying the JSON returned by the server with the initial state of the document (just like the old API does).
Does that seem sensible to you?
What I actually need here is access to the new revision id (to be able to generate a diff URL for all edits made via WDTK) but it feels sensible to also add the ability to return the full edited document in the same go.
from wikidata-toolkit.
Here's the relevant discussion: #403 (comment)
WDTK currently implements option 1. You seem to be proposing fifth option like this:
- Do not return updated entity from edit operations.
- Sacrifice nice edit messages and use
wbeditentity
for everything. - Prohibit blind edits and require base entity document to create
XUpdateBuilder
objects. - Fetch the new document after performing the edit via
wbgetentities
. - If base entity was provided when creating
XUpdateBuilder
, use it to return updated entity from edit functions, otherwise returnnull
(or rather emptyOptional
).
option | complexity | performance | summaries | API |
---|---|---|---|---|
1 | high | perfect | nice | less complete |
2 | trivial | extra bandwidth | ugly | complete |
3 | highest | possibly extra roundtrip | nice | less complete |
4 | high | extra roundtrip | nice | complete |
5 | highest | ? | nice | complete |
I don't remember why an extra network roundtrip might be necessary in case 3 and whether it would also apply to case 5. I guess it might have something to do with either concurrent edits or incomplete responses to edit requests.
I think it is a bit weird for WDTK to fake returning modified entity when the underlying API does not always support it and where it does, the response is sometimes subtly different from fresh fetch. WDTK users can always do it themselves with a single method call that applies the edit to the base revision they have. I have certainly planned this "apply edit locally" API, but I don't think I have implemented it yet. You would probably have to implement it first if you want to return modified entity from edit methods.
This issue is about returning revision ID rather than the whole updated document. I think that was not possible with all Wikibase APIs when I was implementing this, so I omitted the functionality.
from wikidata-toolkit.
Ah, thanks for bringing back this discussion, I also had the feeling we had discussed that earlier.
I think it is a bit weird for WDTK to fake returning modified entity when the underlying API does not always support it and where it does, the response is sometimes subtly different from fresh fetch. WDTK users can always do it themselves with a single method call that applies the edit to the base revision they have. I have certainly planned this "apply edit locally" API, but I don't think I have implemented it yet. You would probably have to implement it first if you want to return modified entity from edit methods.
Yes, I do not want to "apply the edit locally", in the sense that I do not want to re-implement the logic that the Wikibase server is holding. But as far as I can tell the responses of all of the actions we currently support make it really easy to return an updated document state. By relying on those JSON responses I think the risk that we are getting out of sync is really low.
For instance, if you use wbsetaliases
to add certain aliases and remove others in a language, the server responds with the final list of all aliases in that language. So you can just take that and insert it in the document in place of all previous aliases to get the new state. No need to worry about the order in which things are added and deleted or manually retrieving the untouched aliases.
This issue is about returning revision ID rather than the whole updated document. I think that was not possible with all Wikibase APIs when I was implementing this, so I omitted the functionality.
From what I can tell, all API actions we use return the new revision id.
The thing is: as a user there is no workaround for this functionality. I can fetch the state of the document immediately after, but I have no guarantee that no other edit was made in the meantime - so perhaps the latest revision id is not the one of the edit I just made. I guess I could retrieve the history of the entity (although WDTK does not support that yet) and try to match the edit I made to find it in the list, but do we agree that it's really messy? Or how else do you suggest I generate a diff URL?
from wikidata-toolkit.
The thing is: as a user there is no workaround for this functionality. I can fetch the state of the document immediately after, but I have no guarantee that no other edit was made in the meantime - so perhaps the latest revision id is not the one of the edit I just made. I guess I could retrieve the history of the entity (although WDTK does not support that yet) and try to match the edit I made to find it in the list, but do we agree that it's really messy? Or how else do you suggest I generate a diff URL?
Indeed, if you need diff URL, there's no way around parsing the new revision ID out of the response.
Reconstructing whole entities will be quite an effort though. Plus concurrent edits will make the result as inaccurate as just applying edits locally.
from wikidata-toolkit.
Plus concurrent edits will make the result as inaccurate as just applying edits locally.
Ah that's a good point. Then let's go for just exposing the revision id and not the edited entity.
For the sake of making it easier to return more data in the future without breaking the method signature, I would still wrap this revision id in an object (to which we could add fields later if needed).
from wikidata-toolkit.
Related Issues (20)
- Duplicated statements with the editor.editEntityDocument api HOT 4
- Generic method to create new EntityDocument in WikibaseDataEditor
- Release? HOT 3
- Update Javadocs HOT 1
- Built-in server HOT 6
- Support EDTF HOT 5
- Migrate to <dependencyManagement> to control versions of dependencies HOT 1
- Wrong password gives unclear message HOT 2
- Deserializing a property with `localMedia` datatype fails
- Remove datatype IRI from Wikibase data model implementation HOT 1
- Rename to Wikibase-Toolkit or something else? HOT 2
- OAuth2 support
- Incorrect behavior when converting multiple non-existent filenames to mids
- Support the new Wikibase REST API HOT 2
- Why does wdt use /other/wikidata/ instead of /wikidatawiki/entities/? HOT 3
- WbGetEntitiesAction cannot search media-info for titles containing "-" HOT 3
- Drop support for Java 8
- JSON deserialization error in RdfSerializationExample
- WmfOnlineDailyDumpFile incorrectly checks for availability HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wikidata-toolkit.