I'm trying to use the UniqueRequestToken parameter of create_hit as documented here. It doesn't show up as a parameter in boto.mturk.connection.MTurkConnection.create_hit. I tried to use it, guessing that it would be called unique_request_token, and got the following:
TypeError: create_hit() got an unexpected keyword argument 'unique_request_token'
Does boto simply not support that parameter? Is there any way to get around this, short of patching the boto client?
It is not implemented by Boto. You need to patch Boto to add this if you want to continue using Boto.
Alternatively, you can use my Python mTurk API. You'd make this request like:
from mturkcore import MechanicalTurk
m = MechanicalTurk()
m.create_request("CreateHIT", {..."UniqueRequestToken":"..."})
I personally believe mine is a better option because it uses the exact names in the documentation and supports the entire API. If a new name is added, it will (hopefully) be supported by mine even if I do not update :)
Best of luck!
Related
In the below code I'm attempting to use the, 'RSA_V1_5_SHA256', algorithm to create a signature for connecting to an API. However, despite the documentation having it written this way, it doesn't seem to recognize algorithm as a valid argument.
Here's the documentation linked as well,
https://pyauth.github.io/requests-http-signature/#asymmetric-key-algorithms
auth = HTTPSignatureAuth(
algorithm=algorithms.RSA_V1_5_SHA256, key=preshared_secret, key_id=signature_key_id
)
This is the specific error that's being returned,
TypeError: __init__() got an unexpected keyword argument 'algorithm'.
I assume perhaps the documentation may be outdated, as I need to pass a passphrase that was used when I created the public and private keys, to properly authenticate my requests to said API... and passphrase/password isn't an acceptable argument in the other available algorithms based on what I've seen in the source code for this library.
Any help is appreciated!
You're totally right and the docs aren't updated, by checking the source code we can see that the __init__ method for the HTTPSignatureAuth class has no algorithm argument. Instead we find a signature_algorithm parameter (also we can see that this is the parameter that we need - source) so I would go with that:
auth = HTTPSignatureAuth(
signature_algorithm=algorithms.RSA_V1_5_SHA256, key=preshared_secret, key_id=signature_key_id
)
The changes were made in version v0.3.0 so if you use a previous version you will be able to use algorithm as the argument. But I would go with the first approach. (Note that version v0.3.0 was released 23 days ago so it's pretty recent and they may update the docs soon!
I'm using the Metaplex python-api (https://github.com/metaplex-foundation/python-api) to update an existing NFT.
There is the update_token_metadata function (https://github.com/metaplex-foundation/python-api/blob/441c2ba9be76962d234d7700405358c72ee1b35b/metaplex/transactions.py#L110) that enable changing many of the NFT data - but not the primary_sale_happened property.
I tried to change the update_metadata_instruction_data function, but it didn't work.
the Python API is very outdated. If you are not absolutely limited to using Python you should rather have a look at JS packages or rust crates. There is no public implementation for set_primary_sale_happened in the python API.
To set field primary_sale_happened to true a special instruction has to be called similary to e.g. the authority fields. it cannot be changed through a simple data update.
Metaboss has an implementation of how to do it in rust.
I have a script which does the following:
Create campaign
Create AdSet (requires campaign_id)
Create AdCreative (requires adset_id)
Create Ad (requires creative_id and adset_id)
I am trying to lump all of them into a batch request. However, I realized that my none of these gets created except for my campaign (step 1) if I use remote_create(batch=my_batch). This is probably due to the dependencies of the ids that are needed in by each of the subsequent steps.
I read the documentation and it mentions that one can "Specifying dependencies between operations in the request" (https://developers.facebook.com/docs/graph-api/making-multiple-requests) between calls via {result=(parent operation name):(JSONPath expression)}
Is this possible with the python API?
Can this be achieved with the way I am using remote_creates?
Unfortunately python sdk doesn't currently support this. There is a github issue for it: https://github.com/facebook/facebook-python-ads-sdk/issues/256.
I have also encountered this issue also and have described my workaround in the comments on the issue:
"I found a decent workaround for getting this behaviour without too much trouble. Basically I set the id fields that have dependencies with values like "{result=:$,id}" and prior to doing execute() on the batch object I iterate over ._batch and add as the 'name' entry. When I run execute sure enough it works perfectly. Obviously this solution does have it's limitations such where you are doing multiple calls to the same endpoint that need to be fed into other endpoints and you would have duplicated resource names and would need to customize the name further to string them together.
Anyways, hope this helps someone!"
I'm using a REST wrapper in Python called Hammock. Better than I can explain "Hammock is a fun module lets you deal with rest APIs by converting them into dead simple programmatic APIs. It uses popular requests module in backyard to provide full-fledged rest experience."
It will turn api.website/end/point/ into website.end.point which makes working with the API pretty simple. The issue I've run into is when an endpoint has a character in it that Python does not allow in names, '-' in this case (ex api.website/end-point/). Accessing an endpoint like this turns into website.end-point, which is invalid python code.
I looked and '-' is a totally valid character to have in a REST endpoint name. Is there a way to allow this character, maybe the equivalent of a character escape or something? I think I could fix it in the inner code of the module, but figure that's probably a bad way to go about this. Any ideas?
I was able to fix this by using 'website("end-point")' instead of 'website.end-point'. I hope this helps someone else out.
https://github.com/kadirpekel/hammock/issues/20
The python-couchdb package (used as import couchdb) provides a db.view() function to access a couchdb "_view", but how do you access a "_show" or "_list" function?
This was asked before (http://stackoverflow.com/questions/5491851/couchdb-and-python-how-to-use-show-and-list-functions) and 1 of the authors said that it was now included in the library, but he doesn't mention HOW to use it (db.show() doesn't work) and I can't find any documentation for it online.
Can anyone let me know the function/method - or - point me at a page that explains how to do it. I'm particularly interested in "_show".
Currently, you need to get couchdb-python from repository: there are implemented Database methods to call _show, _list and _update functions.