AZURE Cognitive Serivces -> KeyError: 'Endpoint' - azure-cognitive-services

I am using the SDK (Python) for Computer Vision published in Mocrosoft Docs (https://learn.microsoft.com/es-es/azure/cognitive-services/computer-vision/quickstarts-sdk/python-sdk).
When I run the code, this error occurs:
Traceback (most recent call last):
File "c:/analyze_image_local.py", line 68, in <module>
description_result = computervision_client.describe_image_in_stream(local_image)
File "C:\Anaconda3\lib\site-packages\azure\cognitiveservices\vision\computervision\operations\_computer_vision_client_operations.py", line 1202, in describe_image_in_stream
request = self._client.post(url, query_parameters, header_parameters, body_content)
File "C:\Anaconda3\lib\site-packages\msrest\service_client.py", line 193, in post
request = self._request('POST', url, params, headers, content, form_content)
File "C:\Anaconda3\lib\site-packages\msrest\service_client.py", line 108, in _request
request = ClientRequest(method, self.format_url(url))
File "C:\Anaconda3\lib\site-packages\msrest\service_client.py", line 155, in format_url
base = self.config.base_url.format(**kwargs).rstrip('/')
KeyError: 'Endpoint'

I rather used the REST API method (https://learn.microsoft.com/en-us/azure/cognitive-services/computer-vision/quickstarts/python-disk)
However, it can be useful to complete the endpoint using this command line:
analyze_url = endpoint + "vision/v2.1/analyze"

Simply run the following command to reinstall customvision SDK worked for me.
pip uninstall azure-cognitiveservices-vision-customvision
pip install azure-cognitiveservices-vision-customvision

Related

Custom timetable not registered by airflow webserver in Cloud Composer 1

I've recently created custom timetable. Worked perfectly locally (python==3.9.12, airflow==2.3.0), so decided to upload it to plugins folder in my Cloud Composer (version==1.18.11, airflow==2.2.5). While scheduler picks up timetable and dag is run based on it, trying to open dag in UI throws me this error window:
Something bad has happened.
Airflow is used by many users, and it is very likely that others had similar problems and you can easily find
a solution to your problem.
Consider following these steps:
* gather the relevant information (detailed logs with errors, reproduction steps, details of your deployment)
* find similar issues using:
* GitHub Discussions
* GitHub Issues
* Stack Overflow
* the usual search engine you use on a daily basis
* if you run Airflow on a Managed Service, consider opening an issue using the service support channels
* if you tried and have difficulty with diagnosing and fixing the problem yourself, consider creating a bug report.
Make sure however, to include all relevant details and results of your investigation so far.
Python version: 3.8.12
Airflow version: 2.2.5+composer
Node: 67b211ed8faa
-------------------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/python3.8/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/opt/python3.8/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/python3.8/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/opt/python3.8/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/opt/python3.8/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/python3.8/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/www/auth.py", line 51, in decorated
return func(*args, **kwargs)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/www/decorators.py", line 108, in view_func
return f(*args, **kwargs)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/www/decorators.py", line 71, in wrapper
return f(*args, **kwargs)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/utils/session.py", line 70, in wrapper
return func(*args, session=session, **kwargs)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/www/views.py", line 2328, in tree
dag = current_app.dag_bag.get_dag(dag_id)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/utils/session.py", line 70, in wrapper
return func(*args, session=session, **kwargs)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/models/dagbag.py", line 186, in get_dag
self._add_dag_from_db(dag_id=dag_id, session=session)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/models/dagbag.py", line 261, in _add_dag_from_db
dag = row.dag
File "/opt/python3.8/lib/python3.8/site-packages/airflow/models/serialized_dag.py", line 180, in dag
dag = SerializedDAG.from_dict(self.data) # type: Any
File "/opt/python3.8/lib/python3.8/site-packages/airflow/serialization/serialized_objects.py", line 951, in from_dict
return cls.deserialize_dag(serialized_obj['dag'])
File "/opt/python3.8/lib/python3.8/site-packages/airflow/serialization/serialized_objects.py", line 877, in deserialize_dag
v = _decode_timetable(v)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/serialization/serialized_objects.py", line 167, in _decode_timetable
raise _TimetableNotRegistered(importable_string)
airflow.serialization.serialized_objects._TimetableNotRegistered: Timetable class '<enter_your_timetable_plugin_name>.<enter_your_timetable_class_name>' is not registered
Going to window Plugins shows that no plugins are added (both Cloud Composer==2.0.15, airflow==2.2.5) and my local setup uploads plugin properly.
What's really interesting that while having same airflow version, both versions of Cloud Composer works differently.
I don't override any of default airflow variables, nor that should impact anything that's described here.
Many many thanks for any suggestions.

pip search not working on pypi repository

I have setup a PyPi repo in Artifactory, but I cannot search uploaded packages with pip.
I created a PyPi repo in Artifactory and pushed two versions of an example package, which worked perfectly. The package and it's two versions is present in Artifactory under the correct repo. Running pip search and trying to find this package results in a timeout.
Uploading the packages dind't present any issues at all.
I have tried without /simple as well.
pip search example -i http://artifactory_server/api/pypi/pypi-repo/simple
produces the following:
Exception:
Traceback (most recent call last):
File "c:\python27\lib\site-packages\pip\_internal\cli\base_command.py", line 179, in main
status = self.run(options, args)
File "c:\python27\lib\site-packages\pip\_internal\commands\search.py", line 48, in run
pypi_hits = self.search(query, options)
File "c:\python27\lib\site-packages\pip\_internal\commands\search.py", line 65, in search
hits = pypi.search({'name': query, 'summary': query}, 'or')
File "c:\python27\lib\xmlrpclib.py", line 1243, in __call__
return self.__send(self.__name, args)
File "c:\python27\lib\xmlrpclib.py", line 1602, in __request
verbose=self.__verbose
File "c:\python27\lib\site-packages\pip\_internal\download.py", line 823, in request
headers=headers, stream=True)
File "c:\python27\lib\site-packages\pip\_vendor\requests\sessions.py", line 581, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "c:\python27\lib\site-packages\pip\_internal\download.py", line 403, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "c:\python27\lib\site-packages\pip\_vendor\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "c:\python27\lib\site-packages\pip\_vendor\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "c:\python27\lib\site-packages\pip\_vendor\requests\adapters.py", line 529, in send
raise ReadTimeout(e, request=request)
ReadTimeout: HTTPConnectionPool(host='artifactory_server', port=80): Read timed out. (read timeout=15)
Any ideas are most welcome.
Thanks.
Since you are not using https, you need to add the following option at the end of your command
--trusted-host artifactory_server

RobotFramework - Importing test library "AutoItLibrary" failed: Initializing test library 'AutoItLibrary' with no arguments failed

Can anyone support me this case?
I install Robotframework to a machine (win10 64b). The versions in my machine:
Python3.7.2 (32b)
pywin32==224 (32b)
robotframework==3.1.1
robotframework-autoitlibrary==1.2.3
robotframework-ride==1.7.3.1
robotframework-seleniumlibrary==3.3.1
wxPython==4.0.4 (32b)
Import AutoItLibary, it is always red, Ride error log shows:
Traceback (most recent call last):
Initializing test library 'AutoItLibrary' with no arguments failed: RobotNotRunningError: Cannot access execution context
Traceback (most recent call last):
File "c:\python37-32\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 167, in _get_instance
return libcode(*self.positional_args, **dict(self.named_args))
File "c:\python37-32\lib\site-packages\AutoItLibrary\__init__.py", line 88, in __init__
self._OutputDir = self._get_log_dir()
File "c:\python37-32\lib\site-packages\AutoItLibrary\__init__.py", line 182, in _get_log_dir
variables = BuiltIn().get_variables()
File "c:\python37-32\lib\site-packages\robot\libraries\BuiltIn.py", line 1293, in get_variables
return self._variables.as_dict(decoration=is_falsy(no_decoration))
File "c:\python37-32\lib\site-packages\robot\libraries\BuiltIn.py", line 75, in _variables
return self._namespace.variables
File "c:\python37-32\lib\site-packages\robot\libraries\BuiltIn.py", line 71, in _namespace
return self._get_context().namespace
File "c:\python37-32\lib\site-packages\robot\libraries\BuiltIn.py", line 66, in _get_context
raise RobotNotRunningError('Cannot access execution context')
File "c:\python37-32\lib\site-packages\robotide\spec\librarymanager.py", line 87, in _fetch_keywords
return get_import_result(path, library_args)
File "c:\python37-32\lib\site-packages\robotide\spec\libraryfetcher.py", line 24, in get_import_result
lib = robotapi.TestLibrary(path, args)
File "c:\python37-32\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 54, in TestLibrary
lib.create_handlers()
File "c:\python37-32\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 100, in create_handlers
self._create_handlers(self.get_instance())
File "c:\python37-32\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 159, in get_instance
self._libinst = self._get_instance(self._libcode)
File "c:\python37-32\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 169, in _get_instance
self._raise_creating_instance_failed()
File "c:\python37-32\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 314, in _raise_creating_instance_failed
% (self.name, args_text, msg, details))
20190326 17:31:22.876 [INFO]: Found Robot Framework version 3.1.1 from c:\python37-32\lib\site-packages\robot.
20190326 17:31:22.876 [INFO]: Started RIDE 1.7.3.1 using python version 3.7.2 with wx version 4.0.4 in win32. ```
I had the same problem with the robotframework-autoitlibrary.
The way I found to fix and use autoit in RF was to uninstall the "robotframework-autoitlibrary" and install the "autoitlibrary" found here: https://code.google.com/archive/p/robotframework-autoitlibrary/ with python setup.py install as Admin.
Initializing error is now gone.
AutoItLibrary is not built in with robot framework you need to import the library.
pip install robotframework-autoitlibrary

iprof and iprof_totals profiling error

I get this error after trying :
openmdao iprof x.py
or
openmdao iprof_totals x.py
on my terminal. Any idea why it could be? Do we have a simple sample code where the iprof works smoothly.
Traceback (most recent call last):
File "/home/user/miniconda3/bin/openmdao", line 11, in
sys.exit(openmdao_cmd())
File "/home/user/miniconda3/lib/python3.6/site-packages/openmdao/utils/om.py", line 403, in openmdao_cmd
options.executor(options)
File "/home/user/miniconda3/lib/python3.6/site-packages/openmdao/devtools/iprofile.py", line 373, in _iprof_totals_exec
_iprof_py_file(options)
File "/home/user/miniconda3/lib/python3.6/site-packages/openmdao/devtools/iprofile.py", line 429, in _iprof_py_file
_finalize_profile()
File "/home/user/miniconda3/lib/python3.6/site-packages/openmdao/devtools/iprofile.py", line 183, in _finalize_profile
qfile, qclass, qname = find_qualified_name(filename, int(line), cache, full=False)
File "/home/user/miniconda3/lib/python3.6/site-packages/openmdao/devtools/iprof_utils.py", line 73, in find_qualified_name
with open(filename, 'Ur') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'packages/openmdao/jacobians/jacobian.py'
I looked into this and there is currently a bug when using 'openmdao iprof' and 'openmdao iprof_totals' on a version of OpenMDAO that was not installed from an OpenMDAO repository using 'pip install -e'. I put a story in our bug tracker to fix it.

How to add a custom parser to logster?

I want to track the HTTP response codes returned by my nginx web-server, using logster.
1) I found and installed logster. I also pip-installed pygtail, which is required for logster.
https://github.com/etsy/logster
2) I found a python script that parses nginx access_log and placed it in the parsers subdir.
https://github.com/metabrainz/logster/blob/master/musicbrainz/logster/NginxStatus.py
...but when I run the logster command, I get a python exception:
Traceback (most recent call last):
File "/usr/local/bin/logster", line 5, in <module>
pkg_resources.run_script('logster==0.0.1', 'logster')
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 505, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1245, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/local/lib/python2.7/dist-packages/logster-0.0.1-py2.7.egg/EGG-INFO/scripts/logster", line 449, in <module>
main()
File "/usr/local/lib/python2.7/dist-packages/logster-0.0.1-py2.7.egg/EGG-INFO/scripts/logster", line 380, in main
module = __import__(module_name, globals(), locals(), [parser_name])
ImportError: No module named NginxStatus1
````
What am I doing wrong?
The exception error was rather misleading: the file was placed in the right place (the parsers subdir), but - as it turns out- logster must be re-setup after a new parser is added (this isn't documented, unfortunately). so just run:
sudo python setup.py install
in the logster directory and things should start working correctly.

Resources