Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] everware.yml with volumes #190 #193

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

igormusinov
Copy link
Contributor

mount files downloaded from into /notebook/data
can't mount in /notebooks (it deletes git files)

mount files downloaded from <url> into /notebook/data
can't mount in /notebooks (it deletes git files)
text = yaml.load(file)
volumes = []
for element in text:
volumes += text.get(element).get("volumes")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's rename it into 'data' ('volumes' is already taken)
also it should be possible to specify exact location inside container where data volume should be mapped (or use '/notebook/data' by default)

self.download_file(volume)

def download_file(self, url):
import urllib
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should put some info into log about starting download, file size, etc

@@ -371,6 +373,9 @@ def start(self, image=None):
yield self.remove_old_container()
self.log.info("Starting container from image: %s" % image_name)
self._add_to_log('Creating container')
#can't mount into /notebooks folder - it deletes all git files
if self.everware_yml_param.get("directory_volume"):
self.volumes = {self.everware_yml_param.get("directory_volume") : "/notebook/data"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

directory to map data folder to ('/notebook/data') should be defined inside parse_everware_yml

@@ -177,3 +184,30 @@ def load_state(self, state):
if key in state:
setattr(self, key, state[key])

def parse(self, everware_yml):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make function name more specific, parse_everware_yml?

directory_volume = self._repo_dir + "-volume"
os.mkdir(directory_volume)
try:
urllib.request.urlretrieve(url, directory_volume + '/' + filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this call is blocking, so the server will stop being responsive while doing this. Take a look at the OAuthAuthenticator and co for an example of using a non-blocking HTTP client in tornado

Copy link
Member

@anaderi anaderi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs fixing and tests as well

@@ -1,9 +1,13 @@
import re
import git
from concurrent.futures import ThreadPoolExecutor
from tornado import gen
from tornado import gen,concurrent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pep8 (space after comma)

setattr(self, key, state[key])

def download_file(self, url):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need this?

try:
n_check_connection = 1
self.log.info("Downloading from xrootd server %s" % url_struct.hostname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specify destination as well

http_client.close()
except:
self.log.info("Something went wrong during downloading from %s " % url_struct.hostname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print exception details here

@@ -118,6 +122,34 @@ def prepare_local_repo(self):
else:
return True

@gen.coroutine
def prepare_everware_yml(self, _user_log):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call it 'parse_repo_everware_yml'

self.log.info("Downloading from http server %s" % url_struct.hostname)
response = yield http_client.fetch(url_struct.geturl())
with open(self.directory_data + '/' + filename, "ab") as f:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why mode is "ab"? not "wb"?

for data in all_data:
if type(data) == dict:
url = data.get("url")
ssl = data.get("ssl")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssl variable should be initialised above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants