I am trying to load the ontology http://semrob-ontology.mpi.aass.oru.se/OntoCity.owl using the OwlReady python library
from owlready2 import *
onto = get_ontology("http://semrob-ontology.mpi.aass.oru.se/OntoCity.owl").load()
The traceback thread is as below:
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/owlready2/namespace.py in load(self, only_local, fileobj, reload, reload_if_newer, **args)
769 if _LOG_LEVEL: print("* Owlready2 * ...loading ontology %s from %s..." % (self.name, f), file = sys.stderr)
--> 770 try: fileobj = urllib.request.urlopen(f)
771 except: raise OwlReadyOntologyParsingError("Cannot download '%s'!" % f)
HTTPError: HTTP Error 308: Permanent Redirect
During handling of the above exception, another exception occurred:
OwlReadyOntologyParsingError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/owlready2/namespace.py in load(self, only_local, fileobj, reload, reload_if_newer, **args)
769 if _LOG_LEVEL: print("* Owlready2 * ...loading ontology %s from %s..." % (self.name, f), file = sys.stderr)
770 try: fileobj = urllib.request.urlopen(f)
--> 771 except: raise OwlReadyOntologyParsingError("Cannot download '%s'!" % f)
772 try: new_base_iri = self.graph.parse(fileobj, default_base = self.base_iri, **args)
773 finally: fileobj.close()
OwlReadyOntologyParsingError: Cannot download 'http://purl.org/dc/elements/1.1'!
How to resolve this error?
Related
I have a problem: I can't see to load objects from dbfs (data bricks file system) outside of spark (I can load the data fine with spark but not with pandas).
The objects we want to load are joblib and pickled files.
corps_encoder = "/dbfs:/mnt/xxxx/encoders/corpsEncoder.joblib"
corpsEncoding = joblib.load(f'/dbfs:/mnt/xxxx/encoders/corpsEncoder.joblib')
Here the error message:
FileNotFoundError: [Errno 2] No such file or directory: '/dbfs:/mnt/xxxx/encoders/corpsEncoder.joblib'
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<command-2364347171462503> in <module>
1 #corps_encoder = "/dbfs:/mnt/xxxx/encoders/corpsEncoder.joblib"
----> 2 corpsEncoding = joblib.load(f'/dbfs:/mnt/xxxx/encoders/corpsEncoder.joblib')
/databricks/python/lib/python3.8/site-packages/joblib/numpy_pickle.py in load(filename, mmap_mode)
575 obj = _unpickle(fobj)
576 else:
--> 577 with open(filename, 'rb') as f:
578 with _read_fileobject(f, filename, mmap_mode) as fobj:
579 if isinstance(fobj, str):
FileNotFoundError: [Errno 2] No such file or directory: '/dbfs:/mnt/xxxx/encoders/corpsEncoder.joblib'
Any idea of how to load this type of file on db?
I am trying to understand the Flink Checkpointing system (in PyFlink). This is why I created a playground for it. Here is my environment
env = StreamExecutionEnvironment.get_execution_environment()
config = Configuration(j_configuration=get_j_env_configuration(env._j_stream_execution_environment))
config.set_integer("python.fn-execution.bundle.size", 1000)
env.set_runtime_mode(RuntimeExecutionMode.STREAMING)
env.enable_checkpointing(3000)
env.get_checkpoint_config().set_checkpointing_mode(CheckpointingMode.AT_LEAST_ONCE)
env.get_checkpoint_config().set_checkpoint_storage(FileSystemCheckpointStorage('file:///home/ubuntu/checkpoints'))
env.get_checkpoint_config().set_fail_on_checkpointing_errors(True)
env.get_checkpoint_config().set_tolerable_checkpoint_failure_number(1)
and I use state with a simple map function as
class RandomRaiserMap(MapFunction):
def open(self, runtime_context: RuntimeContext):
state_desc = ValueStateDescriptor('cnt', Types.INT())
self.cnt_state = runtime_context.get_state(state_desc)
def map(self, value: Row):
cnt = self.cnt_state.value()
self.cnt_state.update(1 if cnt is None else cnt + 1)
if random.random() < 0.001:
raise Exception("Planted")
return Row(count=self.cnt_state.value(), **value.as_dict())
I used Kafka source (FlinkKafkaConsumer) as
deserialization_schema = JsonRowDeserializationSchema.builder() \
.type_info(Types.ROW_NAMED(["seq", "payload", "event_time"], [Types.INT(), Types.STRING(), Types.SQL_TIMESTAMP()])).build()
source = FlinkKafkaConsumer(
topics='test_checkpoint_sequence_2',
deserialization_schema=deserialization_schema,
properties={'bootstrap.servers': 'localhost:9092'}
)
Now, when start to execute job,
3> +I[1,273328,23fe377010c55a18,2022-08-02 12:36:50.325000]
3> +I[2,273329,79782a6af4a9badb,2022-08-02 12:36:50.336000]
3> +I[3,273330,d3537b0b9aedf6f9,2022-08-02 12:36:50.348000]
3> +I[4,273331,d600824835e4f04d,2022-08-02 12:36:50.359000]
3> +I[5,273332,e1e0851bfbe743ab,2022-08-02 12:36:50.370000]
3> +I[6,273333,27a547b6d4469ac0,2022-08-02 12:36:50.381000]
3> +I[7,273334,f12da6dbccbfc1be,2022-08-02 12:36:50.392000]
Exception in thread read_grpc_client_inputs:
Traceback (most recent call last):
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/site-packages/apache_beam/runners/worker/data_plane.py", line 598, in <lambda>
target=lambda: self._read_inputs(elements_iterator),
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/site-packages/apache_beam/runners/worker/data_plane.py", line 581, in _read_inputs
for elements in elements_iterator:
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/site-packages/grpc/_channel.py", line 426, in __next__
return self._next()
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/site-packages/grpc/_channel.py", line 826, in _next
raise self
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
status = StatusCode.CANCELLED
details = "Multiplexer hanging up"
debug_error_string = "UNKNOWN:Error received from peer ipv6:%5B::1%5D:38775 {grpc_message:"Multiplexer hanging up", grpc_status:1, created_time:"2022-08-02T12:36:53.274140888+00:00"}"
>
Traceback (most recent call last):
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/site-packages/apache_beam/runners/worker/data_plane.py", line 470, in input_elements
element = received.get(timeout=1)
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/queue.py", line 178, in get
raise Empty
_queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/site-packages/apache_beam/runners/worker/sdk_worker.py", line 289, in _execute
response = task()
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/site-packages/apache_beam/runners/worker/sdk_worker.py", line 362, in <lambda>
lambda: self.create_worker().do_instruction(request), request)
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/site-packages/apache_beam/runners/worker/sdk_worker.py", line 606, in do_instruction
return getattr(self, request_type)(
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/site-packages/apache_beam/runners/worker/sdk_worker.py", line 644, in process_bundle
bundle_processor.process_bundle(instruction_id))
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/site-packages/apache_beam/runners/worker/bundle_processor.py", line 988, in process_bundle
for element in data_channel.input_elements(instruction_id,
File "/home/ubuntu/miniconda3/envs/py38/lib/python3.8/site-packages/apache_beam/runners/worker/data_plane.py", line 473, in input_elements
raise RuntimeError('Channel closed prematurely.')
RuntimeError: Channel closed prematurely.
3> +I[188,273515,0fec22df999f7054,2022-08-02 12:36:52.362000]
3> +I[189,273516,9587bc4039b1b8d9,2022-08-02 12:36:52.373000]
3> +I[190,273517,e8e2d9dceb66ba15,2022-08-02 12:36:52.384000]
3> +I[191,273518,569c5513e994fa6b,2022-08-02 12:36:52.395000]
3> +I[192,273519,1f2809cd273204f9,2022-08-02 12:36:52.406000]
3> +I[193,273520,2f63560bdbeb2c96,2022-08-02 12:36:52.417000]
When a periodical checkpoint starts, I get this error. However, it manages to write a checkpoint on the given path (like 1f488f8d38f82d55cc342e1d0f676707) and if an error happens, it can recover as well. I am stuck with what the error can be.
I use
Ubuntu 22.04
Java 11
Python 3.8
Flink 1.15.1
apache-flink 1.15.1
I'm starting a project that must be deployed at the Google App Engine. I read that gluon.tools fetch function must be used instead of urllib.request.
Here I have two defs(), the first one runs ok with urllib, the second one with fetch doesn't run.
It looks as if data parameters has the wrong format.
How must be used this fetch function?
I've been looking for examples along the internet but I don't find anything (except the code of fetchfunction).
# -*- coding: utf-8 -*-
from gluon.tools import fetch
import json
import urllib
def gQLquery1():
data = {'query':'{me{username myMachines{name}}}'}
url = 'https://ecostruxure-machine-advisor.se.app/daas/graphql'
Bearer = "Bearer ngU5TkM5yN2m5VCBeJBQ4F3NGjuvecn8FqK7f7Fc"
data = json.dumps(data).encode('utf-8')
headers={'authorization': Bearer,'Content-Type':'application/json'}
req = urllib.request.Request(url, data=data)
req.add_header('authorization', Bearer)
req.add_header('Content-Type', 'application/json')
response = urllib.request.urlopen(req).read()
decoded = json.loads(response)
out = json.dumps(decoded)
return out
def gQLquery2():
data = {'query':'{me{username myMachines{name}}}'}
url = 'https://ecostruxure-machine-advisor.se.app/daas/graphql'
Bearer = "Bearer ngU5TkM5yN2m5VCBeJBQ4F3NGjuvecn8FqK7f7Fc"
#data = json.dumps(data).encode('utf-8')
headers={'authorization': Bearer,'Content-Type':'application/json'}
#req = urllib.request.Request(url, data=data)
#req.add_header('authorization', Bearer)
#req.add_header('Content-Type', 'application/json')
#response = urllib.request.urlopen(req).read()
response = fetch(url, data , headers )
decoded = json.loads(response)
out = json.dumps(decoded)
return out
ticket returned:
Versión
web2py™ Version 2.21.1-stable+timestamp.2020.11.28.04.10.44
Python Python 3.7.4: D:\Oscar\_Particular\web2py\web2py_no_console.exe (prefix: D:\Oscar\_Particular\web2py)
Traceback (most recent call last):
File "D:\Oscar\_Particular\web2py\gluon\tools.py", line 4639, in fetch
from google.appengine.api import urlfetch
File "D:\Oscar\_Particular\web2py\gluon\custom_import.py", line 85, in custom_importer
return base_importer(pname, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'applications.hola'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Oscar\_Particular\web2py\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "D:/Oscar/_Particular/web2py/applications/hola/controllers/default.py", line 126, in <module>
File "D:\Oscar\_Particular\web2py\gluon\globals.py", line 430, in <lambda>
self._caller = lambda f: f()
File "D:/Oscar/_Particular/web2py/applications/hola/controllers/default.py", line 94, in gQLquery2
response = fetch(url, data , headers )
File "D:\Oscar\_Particular\web2py\gluon\tools.py", line 4642, in fetch
html = urlopen(req).read()
File "urllib\request.py", line 222, in urlopen
File "urllib\request.py", line 523, in open
File "urllib\request.py", line 1247, in do_request_
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.
Call to get_execution_role() from notebook instance fails with the error message NoSuchEntityException: An error occurred (NoSuchEntity) when calling the GetRole operation: The user with name <name> cannot be found.
Stack trace:
NoSuchEntityExceptionTraceback (most recent call last)
<ipython-input-1-1e2d3f162cfe> in <module>()
5 sagemaker_session = sagemaker.Session()
6
----> 7 role = get_execution_role()
/home/ec2-user/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/sagemaker/session.pyc in get_execution_role(sagemaker_session)
871 if not sagemaker_session:
872 sagemaker_session = Session()
--> 873 arn = sagemaker_session.get_caller_identity_arn()
874
875 if 'role' in arn:
/home/ec2-user/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/sagemaker/session.pyc in get_caller_identity_arn(self)
701 # Call IAM to get the role's path
702 role_name = role[role.rfind('/') + 1:]
--> 703 role = self.boto_session.client('iam').get_role(RoleName=role_name)['Role']['Arn']
704
705 return role
/home/ec2-user/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/botocore/client.pyc in _api_call(self, *args, **kwargs)
312 "%s() only accepts keyword arguments." % py_operation_name)
313 # The "self" in this scope is referring to the BaseClient.
--> 314 return self._make_api_call(operation_name, kwargs)
315
316 _api_call.__name__ = str(py_operation_name)
/home/ec2-user/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/botocore/client.pyc in _make_api_call(self, operation_name, api_params)
610 error_code = parsed_response.get("Error", {}).get("Code")
611 error_class = self.exceptions.from_code(error_code)
--> 612 raise error_class(parsed_response, operation_name)
613 else:
614 return parsed_response
NoSuchEntityException: An error occurred (NoSuchEntity) when calling the GetRole operation: The user with name <name> cannot be found.
However using boto client directly to get info about the role succeeds. This works fine:
response = client.get_role(
RoleName='role-name',
)['Role']['Arn']
Turns out this is some weird bug that goes away if you stop and start the notebook instance.
I have shutdown and run again the notebook and it works.
PD: I have to run again the code to make effect.
I'm getting a deadlineexceedederror when trying to create a kml file by a cron that starts a task. The error message is
2012-01-30 16:07:47.902 /createkml/ 500 5012ms 0kb AppEngine-Google; (+http://code.google.com/appengine)
0.1.0.2 - - [30/Jan/2012:10:07:47 -0800] "POST /createkml/ HTTP/1.1" 500 0 "http://www.koolbusiness.com/createkmltask/" "AppEngine-Google; (+http://code.google.com/appengine)" "www.koolbusiness.com" ms=5013 cpu_ms=3305 api_cpu_ms=295 cpm_usd=0.091855 queue_name=default task_name=7177535986681131286 instance=00c61b117cf890b99ca52a6b9e7c5f048e72
I 2012-01-30 16:07:42.959
creating file
E 2012-01-30 16:07:47.853
ApplicationError: 5
Traceback (most recent call last):
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__
return handler.dispatch()
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/s~montaoproject/gralumo.356457066048686089/main.py", line 1575, in post
result = urlfetch.fetch(url)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/urlfetch.py", line 263, in fetch
return rpc.get_result()
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 592, in get_result
return self.__get_result_hook(self)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/urlfetch.py", line 371, in _get_fetch_result
raise DeadlineExceededError(str(err))
DeadlineExceededError: ApplicationError: 5
My code is
class CreateKMLTask(webapp2.RequestHandler):
def get(self):
logging.info('creating KML task')
taskqueue.add(url=r'/createkml/')
self.redirect('/')
class CreateKMLHandler(webapp2.RequestHandler):
def post(self):
# Create the file
logging.info('creating file')
file_name = \
files.blobstore.create(mime_type='application/octet-stream')
url = 'http://montaoproject.appspot.com/list.kml'
result = urlfetch.fetch(url)
if not result.content:
return
# Open the file and write to it
logging.info('opening file')
with files.open(file_name, 'a') as f:
f.write(result.content)
# Finalize the file. Do this before attempting to read it.
files.finalize(file_name)
# Get the file's blob key
logging.info('getting blob key of file')
blob_key = files.blobstore.get_blob_key(file_name)
logging.info('new blob key:'+str(blob_key))
im = Image.get_by_id(4468185)
im.primary_image = blob_key
im.put()
logging.info('new image key:'+str(im.primary_image))
logging.info('finished KML handling and put image')
webapp2.Route(r'/createkml/', handler=CreateKMLHandler,
name='createkml'),
webapp2.Route(r'/createkmltask/', handler=CreateKMLTask,
name='createkmltask')
My cron.yaml:
cron:
- description: daily mailout
url: /report/daily
schedule: every 24 hours
- description: daily mailout
url: /report/montaodaily
schedule: every 24 hours
- description: refresh kml
url: /createkmltask/
schedule: every 24 hours
What I'm trying to do is refresh to KML file to a new blob that has the same File ID as before so the call will be the same. What can I do to resolve my timeout problem? I think it should work.
Thanks
This timeout is fetching the url; you can see this in the stack trace. The fetch function defaults to a 5-second timeout.
The URL Fetch docs say you can increase the timeout by passing deadline as an additional argument. For example, deadline=60 would give you a 60-second timeout.
So, try result = urlfetch.fetch(url, deadline=60)