Skip to content

Commit

Permalink
Merge pull request #22 from datmo/fix-windows-build
Browse files Browse the repository at this point in the history
Fix windows build
  • Loading branch information
asampat3090 committed Apr 30, 2018
2 parents 6369850 + 8604ba0 commit 00ed097
Show file tree
Hide file tree
Showing 39 changed files with 215 additions and 146 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ python:
- '3.6'
sudo: required
install:
- pip install pip==9.0.3
- pip install pytest pytest-cov
- pip install coveralls
- python setup.py install
Expand Down
10 changes: 9 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
image:
- Visual Studio 2017
environment:
global:
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
Expand Down Expand Up @@ -35,8 +37,14 @@ init:
install:
- ps: '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12'
- ps: (new-object net.webclient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', 'C:/get-pip.py')
- ps: '[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")'
- ps: 'Restart-Service Docker'
- git config --global user.email "dev@datmo.com"
- git config --global user.name "Datmo Devs"
- "%PYTHON%/python.exe C:/get-pip.py"
- "%PYTHON%/python.exe -m pip install pip==9.0.3"
- "%PYTHON%/Scripts/pip.exe install pytest"
- "%PYTHON%/python.exe setup.py install"
test_script:
- "%PYTHON%/Scripts/pip.exe --version"
- "%PYTHON%/Scripts/py.test"
- "%PYTHON%/Scripts/pytest "
6 changes: 5 additions & 1 deletion datmo/cli/command/task.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import print_function

import shlex
import platform
import prettytable

from datmo.core.util.i18n import get as __
Expand Down Expand Up @@ -52,7 +53,10 @@ def run(self, **kwargs):
}

if not isinstance(kwargs['cmd'], list):
kwargs['cmd'] = shlex.split(kwargs['cmd'])
if platform.system() == "Windows":
kwargs['cmd'] = kwargs['cmd']
else:
kwargs['cmd'] = shlex.split(kwargs['cmd'])

task_dict = {
"gpu": kwargs['gpu'],
Expand Down
5 changes: 3 additions & 2 deletions datmo/cli/command/test/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import shutil
import tempfile
import platform

from datmo.cli.driver.helper import Helper
from datmo.cli.command.project import ProjectCommand
Expand All @@ -23,15 +24,15 @@
class TestProject():
def setup_class(self):
# provide mountable tmp directory for docker
tempfile.tempdir = '/tmp'
tempfile.tempdir = "/tmp" if not platform.system() == "Windows" else None
test_datmo_dir = os.environ.get('TEST_DATMO_DIR',
tempfile.gettempdir())
self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir)
self.cli = Helper()
self.init = ProjectCommand(self.temp_dir, self.cli)

def teardown_class(self):
shutil.rmtree(self.temp_dir)
pass

def test_datmo_init(self):
self.init.parse([
Expand Down
5 changes: 3 additions & 2 deletions datmo/cli/command/test/test_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import os
import shutil
import tempfile
import platform
from io import open
try:
to_unicode = unicode
Expand All @@ -29,14 +30,14 @@
class TestSnapshot():
def setup_class(self):
# provide mountable tmp directory for docker
tempfile.tempdir = '/tmp'
tempfile.tempdir = "/tmp" if not platform.system() == "Windows" else None
test_datmo_dir = os.environ.get('TEST_DATMO_DIR',
tempfile.gettempdir())
self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir)
self.cli_helper = Helper()

def teardown_class(self):
shutil.rmtree(self.temp_dir)
pass

def __set_variables(self):
self.init = ProjectCommand(self.temp_dir, self.cli_helper)
Expand Down
5 changes: 3 additions & 2 deletions datmo/cli/command/test/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import shutil
import tempfile
import platform
from io import open
try:
to_unicode = unicode
Expand All @@ -31,14 +32,14 @@
class TestTaskCommand():
def setup_class(self):
# provide mountable tmp directory for docker
tempfile.tempdir = '/tmp'
tempfile.tempdir = "/tmp" if not platform.system() == "Windows" else None
test_datmo_dir = os.environ.get('TEST_DATMO_DIR',
tempfile.gettempdir())
self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir)
self.cli_helper = Helper()

def teardown_class(self):
shutil.rmtree(self.temp_dir)
pass

def __set_variables(self):
self.init = ProjectCommand(self.temp_dir, self.cli_helper)
Expand Down
3 changes: 2 additions & 1 deletion datmo/cli/driver/test/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import sys
import tempfile
import platform
from io import open
try:
to_unicode = unicode
Expand All @@ -29,7 +30,7 @@ class TestHelper():

def setup_method(self):
# provide mountable tmp directory for docker
tempfile.tempdir = '/tmp'
tempfile.tempdir = "/tmp" if not platform.system() == "Windows" else None
test_datmo_dir = os.environ.get('TEST_DATMO_DIR',
tempfile.gettempdir())
self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir)
Expand Down
3 changes: 1 addition & 2 deletions datmo/core/controller/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ def get_config_defaults(self):
"class_constructor": "datmo.core.controller.environment.driver.dockerenv.DockerEnvironmentDriver",
"options": {
"filepath": self.home,
"docker_execpath": "docker",
"docker_socket": "unix:///var/run/docker.sock"
"docker_execpath": "docker"
}
},
"storage.local": {
Expand Down
3 changes: 2 additions & 1 deletion datmo/core/controller/code/driver/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def __init__(self, filepath, execpath, remote_url=None):
raise GitExecutionException(__("error",
"controller.code.driver.git.__init__.giterror",
err))
if not semver.match(str(out.split()[2]), ">=1.9.7"):
version = str(out.split()[2].split(".windows")[0])
if not semver.match(version, ">=1.9.7"):
raise GitExecutionException(__("error",
"controller.code.driver.git.__init__.gitversion",
out.split()[2]))
Expand Down
18 changes: 9 additions & 9 deletions datmo/core/controller/code/driver/test/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import shutil
import tempfile
import platform
from io import open
try:
to_unicode = unicode
Expand All @@ -26,14 +27,14 @@ class TestGitCodeDriver():
"""
def setup_method(self):
# provide mountable tmp directory for docker
tempfile.tempdir = '/tmp'
tempfile.tempdir = "/tmp" if not platform.system() == "Windows" else None
test_datmo_dir = os.environ.get('TEST_DATMO_DIR',
tempfile.gettempdir())
self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir)
self.git_code_manager = GitCodeDriver(filepath=self.temp_dir, execpath="git")

def teardown_method(self):
shutil.rmtree(self.temp_dir)
pass

def test_instantiation(self):
assert self.git_code_manager != None
Expand Down Expand Up @@ -133,14 +134,13 @@ def test_exists_datmo_files_in_worktree(self):
def test_clone(self):
result = self.git_code_manager.clone("https://github.com/datmo/hello-world.git", mode="https")
assert result and os.path.exists(os.path.join(self.temp_dir, "hello-world",".git"))
shutil.rmtree(os.path.join(self.temp_dir, "hello-world"))
result = self.git_code_manager.clone("https://github.com/datmo/hello-world.git", mode="http")
assert result and os.path.exists(os.path.join(self.temp_dir, "hello-world", ".git"))
shutil.rmtree(os.path.join(self.temp_dir, "hello-world"))
result = self.git_code_manager.clone("https://github.com/datmo/hello-world.git",
repo_name="hello-world-2", mode="http")
assert result and os.path.exists(os.path.join(self.temp_dir, "hello-world-2", ".git"))
if self.git_code_manager.git_host_manager.ssh_enabled:
result = self.git_code_manager.clone("https://github.com/datmo/hello-world.git", mode="ssh")
assert result and os.path.exists(os.path.join(self.temp_dir, "hello-world", ".git"))
shutil.rmtree(os.path.join(self.temp_dir, "hello-world"))
result = self.git_code_manager.clone("https://github.com/datmo/hello-world.git",
repo_name="hello-world-3", mode="ssh")
assert result and os.path.exists(os.path.join(self.temp_dir, "hello-world-3", ".git"))

def test_parse_git_url(self):
parsed = self.git_code_manager._parse_git_url("https://github.com/datmo/hello-world.git", mode="ssh")
Expand Down
6 changes: 3 additions & 3 deletions datmo/core/controller/code/test/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Tests for CodeController
"""
import os
import shutil
import tempfile
import platform
from io import open
try:
to_unicode = unicode
Expand All @@ -20,15 +20,15 @@
class TestCodeController():
def setup_method(self):
# provide mountable tmp directory for docker
tempfile.tempdir = '/tmp'
tempfile.tempdir = "/tmp" if not platform.system() == "Windows" else None
test_datmo_dir = os.environ.get('TEST_DATMO_DIR',
tempfile.gettempdir())
self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir)
self.project = ProjectController(self.temp_dir)
self.code = CodeController(self.temp_dir)

def teardown_method(self):
shutil.rmtree(self.temp_dir)
pass

def test_create(self):
self.project.init("test3", "test description")
Expand Down

0 comments on commit 00ed097

Please sign in to comment.