Aws Batch docker s3.download_fileobj() error - docker

Hello I am launching my docker container through aws Batch.
My aws batch keeps failing. I am currently trying to download a file_object and reupload it to a different s3 bucket. Each time I am getting an OSERROR
first time was:
OSError: [Errno 30] Read-only file system
Here is my download function:
def download(self):
s3 = boto3.client('s3')
file_name = self.flow_cells[10:]
try:
with open(file_name, 'wb') as data:
s3.download_fileobj(
self.source_s3_bucket,
self.source_key,
data
)
return True
except botocore.exceptions.ClientError as error:
print(error.response['Error']['Code'])
The error occurs in the s3.download)fileobj call
It gets flagged when it hits data.
The second time I ran this to check for the error I got
OSError: [Errno 5] Input/output error
The following is my container definition.
container_properties = <<CONTAINER_PROPERTIES
{
"command": [
"--object_key", "Ref::object_key",
"--glacier_s3_bucket", "Ref::glacier_s3_bucket",
"--output_s3_bucket", "Ref::output_s3_bucket",
"--default_s3_bucket", "Ref::default_s3_bucket"
],
"environment": [],
"image": "temp_image_name",
"jobRoleArn": "${aws_iam_role.task-role.arn}",
"memory": 1024,
"mountPoints": [],
"privileged": true,
"readonlyRootFilesystem": false,
"ulimits": [],
"vcpus": 1,
"volumes": [],
"jobDefinitionName": "docker-flowcell-restore-${var.environment}"
}
Here is the full log for the program:
File "src/main.py", line 101, in download
17:10:55
data
17:10:55
File "/usr/local/lib/python3.5/dist-packages/boto3/s3/inject.py", line 678, in download_fileobj
17:10:55
return future.result()
17:10:55
File "/usr/local/lib/python3.5/dist-packages/s3transfer/futures.py", line 73, in result
17:10:55
return self._coordinator.result()
17:10:55
File "/usr/local/lib/python3.5/dist-packages/s3transfer/futures.py", line 233, in result
17:10:55
raise self._exception
17:10:55
File "/usr/local/lib/python3.5/dist-packages/s3transfer/tasks.py", line 126, in __call__
17:10:55
return self._execute_main(kwargs)
17:10:55
File "/usr/local/lib/python3.5/dist-packages/s3transfer/tasks.py", line 150, in _execute_main
17:10:55
return_value = self._main(**kwargs)
17:10:55
File "/usr/local/lib/python3.5/dist-packages/s3transfer/download.py", line 583, in _main
17:10:55
fileobj.write(data)
17:10:55
OSError: [Errno 5] Input/output error

the solve for this is to
os.chdir('/tmp')
Inside the code that the docker container will be running.

Related

Jira create issue returns 405 python

I am using python Jira package and trying to create Jira issue:
from jira import JIRA
jiraOptions = {'server': "http://jira.xxx.com"}
jira = JIRA(options = jiraOptions, basic_auth=(
"xxx", "xxx"))
def create_new_issue(project, summary, description, issuetype, username):
issue_dict = {
'project': {'key': project},
'summary': summary,
'description': description,
'issuetype': {'name': issuetype},
'reporter': {'name': username}
}
new_issue = jira.create_issue(fields=issue_dict)
create_new_issue("p1", "test", "teseset", "Bug", "xxxx")
I get 405 error which I can't figure out where I got wrong:
Traceback (most recent call last):
File ".\jiraUtil.py", line 97, in <module>
create_new_issue("p1", "test", "teseset", "Bug", "xxxx")
File ".\jiraUtil.py", line 58, in create_new_issue
new_issue = jira.create_issue(fields=issue_dict)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\site-packages\jira\client.py", line 1473, in create_issue
r = self._session.post(url, data=json.dumps(data))
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\site-packages\jira\resilientsession.py", line 198, in post
return self.__verb("POST", str(url), data=data, json=json, **kwargs)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\site-packages\jira\resilientsession.py", line 189, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\site-packages\jira\resilientsession.py", line 64, in raise_on_error
raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 405 url: https://jira.xxx.com/rest/api/2/issue
At a guess, "xxxx" user doesn't exist in your Jira Cloud instance, try changing it to "-1" which is unassigned.
I ran into some issues myself doing this, so I built this project - https://github.com/dren79/JiraScripting_public let me know if it helps :)

Installing Selected Parcels time out in CDH5

I'm trying to create a cluster after cloudera manager setup, and when Installing Selected Parcels, it stuck at activating giving the error timed out and the log gives the warning Parcel not distributed but have active state ACTIVATING.
please help, how to resolve this?
Error log
Unexpected exception during download
Traceback (most recent call last):
File "/opt/cloudera-manager/cm-5.5.3/lib/cmf/agent/src/cmf/downloader.py", line 276, in _download
response = self.opener.fetch_url(request)
File "/opt/cloudera-manager/cm-5.5.3/lib/cmf/agent/src/cmf/downloader.py", line 69, in fetch_url
return urllib2.urlopen(request)
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 404, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 422, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1214, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1187, in do_open
r = h.getresponse(buffering=True)
File "/usr/lib/python2.7/httplib.py", line 1051, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 415, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 371, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/usr/lib/python2.7/socket.py", line 476, in readline
data = self._sock.recv(self._rbufsize)
timeout: timed out

How to Setup Geojson as Datasource in TileStache

I have successfully installed TileStache in my server.
Now I have a geojson file and want to serve it through TileStache.
I am new to TileStache and I can't find a clear explanation of how to setup a Geojson in TileStache. Best explanation I can found is here, but it uses a shp file as the datasource.
I want to know how to set it using a Geojson as the datasource.
Edit
I tried adding a tes layer to the config file, so my config file looks like this:
{
"cache":
{
"name": "Test",
"path": "/tmp/stache",
"umask": "0000"
},
"layers":
{
"osm":
{
"provider": {"name": "proxy", "provider": "OPENSTREETMAP"},
"png options": {"palette": "http://tilestache.org/example-palette-openstreetmap-mapnik.act"}
},
"example":
{
"provider": {"name": "mapnik", "mapfile": "examples/style.xml"},
"projection": "spherical mercator"
},
"tes":{
"provider": {
"name": "vector", "driver": "GeoJSON",
"parameters": {"file": "tes.geojson"},
"properties": []
}
}
}
}
When I tried to run using tilestache-server.py -c /etc/TileStache/tilestache.cfg, it gives me error like this:
Error loading Tilestache config:
Traceback (most recent call last):
File "/usr/local/bin/tilestache-server.py", line 5, in <module>
pkg_resources.run_script('TileStache==1.50.1', 'tilestache-server.py')
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 499, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1235, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/EGG-INFO/scripts/tilestache-server.py", line 55, in <module>
app = TileStache.WSGITileServer(config=options.file, autoreload=True)
File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/TileStache/__init__.py", line 342, in __init__
self.config = parseConfigfile(config)
File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/TileStache/__init__.py", line 107, in parseConfigfile
return Config.buildConfiguration(config_dict, dirpath)
File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/TileStache/Config.py", line 218, in buildConfiguration
config.layers[name] = _parseConfigfileLayer(layer_dict, config, dirpath)
File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/TileStache/Config.py", line 448, in _parseConfigfileLayer
_class = Providers.getProviderByName(provider_dict['name'])
File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/TileStache/Providers.py", line 122, in getProviderByName
from . import Vector
File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/TileStache/Vector/__init__.py", line 164, in <module>
from osgeo import ogr, osr
ImportError: No module named osgeo
I can't figure out what is wrong.
ImportError: No module named osgeo
You are missing the GDAL library. It can be quite tricky to install, I got it working on Ubuntu 14.04 by using the PPA ppa:ubuntugis/ubuntugis-unstable, read the instructions in this post over at the GIS Stackexchange.

Sublime Text 2 + Eval in REPL: Handle is Invalid

Using sublime text 2 on windows 8, I've set my key-bindings to:
[
{
"keys": ["ctrl+alt+f"],
"args": {
"id": "repl_f#",
"file": "config/F/Main.sublime-menu"
},
"command": "run_existing_window_command"
},
{
"keys": ["ctrl+shift+enter"],
"args": {
"scope": "selection"
},
"command": "repl_transfer_current"
}
]
But when I press "ctrl+shift+enter" I get the following error. Does anyone know how to resolve this?
Traceback (most recent call last):
File ".\sublime_plugin.py", line 356, in run_
File ".\text_transfer.py", line 123, in run
File ".\sublimerepl.py", line 437, in find_repl
File ".\repls\subprocess_repl.py", line 185, in is_alive
File ".\subprocess.py", line 705, in poll
File ".\subprocess.py", line 874, in _internal_poll
WindowsError: [Error 6] The handle is invalid

Can't activate django admin screen

Error page shows the following:
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/django/core/servers/basehttp.py", line 283, in run
self.result = application(self.environ, self.start_response)
File "/Library/Python/2.6/site-packages/django/core/handlers/wsgi.py", line 273, in call
response = self.get_response(request)
File "/Library/Python/2.6/site-packages/django/core/handlers/base.py", line 153, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Library/Python/2.6/site-packages/django/core/handlers/base.py", line 218, in handle_uncaught_exception
return callback(request, **param_dict)
File "/Library/Python/2.6/site-packages/django/utils/decorators.py", line 93, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Library/Python/2.6/site-packages/django/views/defaults.py", line 30, in server_error
t = loader.get_template(template_name) # You need to create a 500.html template.
File "/Library/Python/2.6/site-packages/django/template/loader.py", line 157, in get_template
template, origin = find_template(template_name)
File "/Library/Python/2.6/site-packages/django/template/loader.py", line 138, in find_template
raise TemplateDoesNotExist(name)
TemplateDoesNotExist: 500.html
Check your Template_Loaders in settings.py. It should look like this to automatically find the default admin templates. The app_directories.Loader is important here.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

Resources