petrbroz / forge-sdk-python Goto Github PK
View Code? Open in Web Editor NEWUnofficial Autodesk Forge SDK for Python.
Home Page: https://petrbroz.github.io/forge-sdk-python/index.html
Unofficial Autodesk Forge SDK for Python.
Home Page: https://petrbroz.github.io/forge-sdk-python/index.html
The line above should return a dict, this makes BaseOAuthClient._set_auth_headers()
raise TypeError: string indices must be integers
Hey! I am trying to create a bucket using OSSClient
below is my code:
from autodesk_forge_sdk import OSSClient, OAuthTokenProvider
from autodesk_forge_sdk.dm import DataRetention
from django.conf import settings
FORGE_CLIENT_ID = settings.FORGE_CLIENT_ID
FORGE_CLIENT_SECRET = settings.FORGE_CLIENT_SECRET
client = OSSClient(OAuthTokenProvider(FORGE_CLIENT_ID, FORGE_CLIENT_SECRET))
def run():
res = client.create_bucket(input("Enter unique bucket name: "), DataRetention.TEMPORARY, "US")
print(res)
I had ensured the bucket name is unique and tried different DataRetention enum, tested the client ID and secret on get_all_buckets
and it's working too. Will be much appreciated if this issue can be resolved!
Same issue on https://petrbroz.github.io/forge-sdk-python/md.html#autodesk_forge_sdk.md.ModelDerivativeClient.submit_job, whenever it deals with Scope
, this issue happened.
Trace:
Traceback (most recent call last):
File "/code/manage.py", line 22, in <module>
main()
File "/code/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.9/site-packages/django_extensions/management/email_notifications.py", line 65, in run_from_argv
super().run_from_argv(argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.9/site-packages/django_extensions/management/email_notifications.py", line 77, in execute
super().execute(*args, **options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.9/site-packages/django_extensions/management/utils.py", line 62, in inner
ret = func(self, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django_extensions/management/commands/runscript.py", line 283, in handle
run_script(script_mod, *script_args)
File "/usr/local/lib/python3.9/site-packages/django_extensions/management/commands/runscript.py", line 161, in run_script
exit_code = mod.run(*script_args)
File "/code/scripts/forge_translate_object.py", line 14, in run
job = client.submit_job(
File "/usr/local/lib/python3.9/site-packages/autodesk_forge_sdk/md.py", line 149, in submit_job
return self._post("/designdata/job", WRITE_SCOPES, json=json, headers=headers).json()
File "/usr/local/lib/python3.9/site-packages/autodesk_forge_sdk/auth.py", line 395, in _post
return BaseClient._post(self, url, form, json, buff, **kwargs)
File "/usr/local/lib/python3.9/site-packages/autodesk_forge_sdk/base.py", line 38, in _post
response = requests.post(url, data=form, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 528, in request
prep = self.prepare_request(req)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 456, in prepare_request
p.prepare(
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 319, in prepare
self.prepare_body(data, files, json)
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 510, in prepare_body
body = self._encode_params(data)
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 97, in _encode_params
for k, vs in to_key_val_list(data):
TypeError: cannot unpack non-iterable Scope object```
The package uses authentication/v1
This will stop working on April 30, 2024
Is there any chance that the package will support Authentication v2 before then ?
Hi, I encountered an error caused by a wrong type annotation.
def get_authorization_url(
client_id: str, response_type: str, redirect_uri: str,
scopes: list[Scope], state: str = None
) -> str
As you can see in the case above, list[Scope]
causes a runtime error because list
is not the right way to type annotate.
It should be changed in List
, imported from typing
.
I'm going to PR a fix in few minutes, I created this issue just for completeness.
Btw, thanks for starting this great work in creating an SDK for Forge API.
I'm likely to start contributing in next weeks as I'll need it for a new project.
The class ReviewsClient is not working properly.
The call reviews=Reviews.get_reviews(project_id)
produces an error where Reviews=ReviewsClient(OAuthTokenProvider(client_id, client_secret))
test_get_object_details()
fails for me because it is called before test_upload_object_buff()
. Therefor no unittest.txt file exists in the bucket.
This happens because the sequence of methods are alphabetical.
An improvement might be to add a testSuite. But I have no experience using it.
https://stackoverflow.com/a/36430378
def test_upload_object_buff(self):
buff = bytes('This is a test...', 'utf-8')
obj = self.client.upload_object(FORGE_BUCKET, 'unittest.txt', buff)
assert obj
def test_upload_object_file(self):
with open(__file__, 'rb') as file:
obj = self.client.upload_object(FORGE_BUCKET, 'unittest.py', file)
assert obj
def test_get_object_details(self): #NOTE: called before test_upload_object_buff()
details = self.client.get_object_details(FORGE_BUCKET, 'unittest.txt')
assert 'objectKey' in details
@Magnus-COWI, I have some bad news. I've been informed that the Review API you contributed to this experimental SDK is only meant for internal use. We will need to remove the functionality from this repo but you are free to continue using it in your own fork.
So, if you haven't done so already, please make sure to fork this repository, and I will be removing the ReviewsClient
later this month.
Any tips on how to implement a way to let the client know what % of the file is uploaded to the bucket?
I have this sdk in my backend, the frontend uploads the file to it and the backend is uploading to forge. I would like to add a query for the front end to know what is the backends' progress.
Thank you, you can close the issue
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.