Skip to content

Commit a9a7736

Browse files
hekaishengqinxuye
authored andcommitted
Add appveyor and fix upload config (#46)
* add appveyor * refine install
1 parent 15dbef3 commit a9a7736

File tree

13 files changed

+229
-30
lines changed

13 files changed

+229
-30
lines changed

.travis.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
language: python
2-
python:
3-
- "2.7"
4-
- "3.5"
5-
- "3.6"
62

73
matrix:
84
include:
9-
- os: linux
5+
- sudo: required
6+
os: linux
7+
python: "2.7"
8+
services:
9+
- docker
10+
env: DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64 PYVER=cp27-cp27mu
11+
- sudo: required
12+
os: linux
13+
python: "3.5"
14+
services:
15+
- docker
16+
env: DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64 PYVER=cp35-cp35m
17+
- sudo: required
18+
os: linux
19+
python: "3.6"
20+
services:
21+
- docker
22+
env: DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64 PYVER=cp36-cp36m
23+
- sudo: required
24+
os: linux
1025
python: "3.7"
1126
dist: xenial
12-
sudo: true
27+
services:
28+
- docker
29+
env: DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64 PYVER=cp37-cp37m
1330
- os: osx
1431
language: generic
1532
env: PYTHON=2.7.12

appveyor.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
environment:
2+
SECUREPSD:
3+
secure: W32PjuuRBQGf05cN6X5EXg8t3/2UsFwvefBlSbioclY=
4+
5+
matrix:
6+
7+
- PYTHON: "C:\\Python35-x64"
8+
PYTHON_VERSION: "3.5.x"
9+
PYTHON_ARCH: "64"
10+
11+
- PYTHON: "C:\\Python36-x64"
12+
PYTHON_VERSION: "3.6.x"
13+
PYTHON_ARCH: "64"
14+
15+
- PYTHON: "C:\\Python37-x64"
16+
PYTHON_VERSION: "3.7.0"
17+
PYTHON_ARCH: "64"
18+
19+
install:
20+
# Prepend newly installed Python to the PATH of this build (this cannot be
21+
# done from inside the powershell script as it would require to restart
22+
# the parent CMD process).
23+
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
24+
25+
# Check that we have the expected version and architecture for Python
26+
- "python --version"
27+
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
28+
29+
# Upgrade to the latest version of pip to avoid it displaying warnings
30+
# about it being out of date.
31+
- "python -m pip install --disable-pip-version-check --user --upgrade pip"
32+
33+
# Install the build dependencies of the project.
34+
- "pip install --upgrade wheel twine setuptools coveralls"
35+
- "pip install -r requirements-dev.txt"
36+
- "pip install -r requirements-extra.txt"
37+
38+
39+
build_script:
40+
- "python setup.py build_ext -i"
41+
# Build tar zip only once
42+
43+
44+
test_script:
45+
- "python -m pytest -p no:warnings --ignore=mars/worker --timeout=1500"
46+
47+
after_test:
48+
49+
# Specify account details for PyPI
50+
- echo [distutils] > %USERPROFILE%\\.pypirc
51+
- echo index-servers = >> %USERPROFILE%\\.pypirc
52+
- echo pypi >> %USERPROFILE%\\.pypirc
53+
- echo [pypi] >> %USERPROFILE%\\.pypirc
54+
- echo repository=https://upload.pypi.org/legacy/ >> %USERPROFILE%\\.pypirc
55+
- echo username=pyodps >> %USERPROFILE%\\.pypirc
56+
- echo password=%SECUREPSD% >> %USERPROFILE%\\.pypirc
57+
58+
on_success:
59+
- echo %APPVEYOR_REPO_TAG%
60+
- echo %APPVEYOR_REPO_TAG_NAME%
61+
- echo %APPVEYOR_REPO_BRANCH%
62+
- ps: >-
63+
If ($env:APPVEYOR_REPO_TAG -eq "true"){
64+
Invoke-Expression "python setup.py bdist_wheel"
65+
if ($env:PYTHON_VERSION -eq "3.6.x" -and $env:PYTHON_ARCH -eq "64")
66+
{
67+
Invoke-Expression "python setup.py sdist --formats=gztar"
68+
}
69+
70+
Invoke-Expression "twine upload --skip-existing dist/*"
71+
}Else {
72+
write-output "Not on a tag commit, won't deploy to pypi"
73+
}

bin/travis-build-wheels.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
# Install a system package required by our library
5+
yum install -y atlas-devel
6+
7+
# Compile wheels
8+
PYBIN=/opt/python/${PYVER}/bin
9+
"${PYBIN}/pip" install -r /io/requirements-dev.txt
10+
"${PYBIN}/pip" install -r /io/requirements-extra.txt
11+
12+
cd /io
13+
"${PYBIN}/python" setup.py bdist_wheel
14+
15+
16+
# Bundle external shared libraries into the wheels
17+
for whl in dist/*.whl; do
18+
auditwheel repair "$whl" -w dist/
19+
done
20+
21+
rm dist/*-linux*.whl

bin/travis-upload.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
#!/bin/bash
22

33
if [ "$TRAVIS_TAG" ]; then
4+
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
5+
sudo chmod 777 bin/*
6+
docker pull $DOCKER_IMAGE
7+
docker run --rm -e "PYVER=$PYVER" -v `pwd`:/io $DOCKER_IMAGE $PRE_CMD /io/bin/travis-build-wheels.sh
8+
else
9+
pip wheel --no-deps .
10+
mkdir dist
11+
cp *.whl dist/
12+
pip install delocate
13+
delocate-wheel dist/*.whl
14+
delocate-addplat --rm-orig -x 10_9 -x 10_10 dist/*.whl
15+
fi
16+
ls dist/
17+
418
echo "[distutils]" > ~/.pypirc
519
echo "index-servers =" >> ~/.pypirc
620
echo " pypi" >> ~/.pypirc
@@ -10,16 +24,7 @@ if [ "$TRAVIS_TAG" ]; then
1024
echo "password=$PASSWD" >> ~/.pypirc
1125

1226
python -m pip install twine
13-
14-
python setup.py sdist --formats=gztar
15-
python setup.py bdist_wheel
16-
17-
for whl in dist/*.whl; do
18-
auditwheel repair $whl -w dist/
19-
done
20-
rm dist/*-linux*.whl
21-
22-
python -m twine upload -r pypi --skip-existing dist/*.tar.gz;
27+
python -m twine upload -r pypi --skip-existing dist/*.whl;
2328
else
2429
echo "Not on a tag, won't deploy to pypi";
2530
fi

mars/actors/pool/tests/test_gevent_pool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import uuid
2121
import time
2222
import unittest
23+
import sys
2324

2425
import gevent
2526

@@ -172,6 +173,7 @@ def distribute(self, uid):
172173
return int(hashlib.sha1(to_binary(uid)).hexdigest(), 16) % (self.n_process - 1) + 1
173174

174175

176+
@unittest.skipIf(sys.platform == 'win32', 'does not run in windows')
175177
class Test(unittest.TestCase):
176178
def setUp(self):
177179
self.exceptions = gevent.hub.Hub.NOT_ERROR

mars/deploy/local/tests/test_cluster.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# limitations under the License.
1616

1717
import unittest
18+
import sys
1819

1920
import numpy as np
2021

@@ -43,6 +44,7 @@ def __init__(self, f=None, **kw):
4344
super(SerializeMustFailOperand, self).__init__(_f=f, **kw)
4445

4546

47+
@unittest.skipIf(sys.platform == 'win32', 'does not run in windows')
4648
class Test(unittest.TestCase):
4749
def setUp(self):
4850
self._old_cache_memory_limit = options.worker.cache_memory_limit

mars/scheduler/tests/test_assigner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get_reply(self):
4141
class Test(unittest.TestCase):
4242

4343
def testAssignerActor(self):
44-
with create_actor_pool(backend='gevent') as pool:
44+
with create_actor_pool(n_process=1, backend='gevent') as pool:
4545
pool.create_actor(ClusterInfoActor, [pool.cluster_info.address],
4646
uid=ClusterInfoActor.default_name())
4747
resource_ref = pool.create_actor(ResourceActor, uid=ResourceActor.default_name())

mars/scheduler/tests/test_main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from mars.scheduler.graph import GraphState
3535

3636

37+
@unittest.skipIf(sys.platform == 'win32', "plasma don't support windows")
3738
class Test(unittest.TestCase):
3839

3940
@classmethod

mars/tensor/execution/tests/test_datasource_execute.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def testCreateSparseExecution(self):
5454

5555
res = self.executor.execute_tensor(t3)
5656
self.assertIsInstance(res[0], SparseNDArray)
57-
self.assertEqual(res[0].dtype, np.int64)
57+
self.assertEqual(res[0].dtype, np.int_)
5858
np.testing.assert_array_equal(res[0].toarray(), mat[..., :2].toarray())
5959
np.testing.assert_array_equal(res[1].toarray(), mat[..., 2:].toarray())
6060

@@ -80,7 +80,7 @@ def testEmptyExecution(self):
8080

8181
res = self.executor.execute_tensor(t, concat=True)
8282
self.assertEqual(res[0].shape, (20, 30))
83-
self.assertTrue(res[0].dtype, np.int64)
83+
self.assertEqual(res[0].dtype, np.int64)
8484
self.assertFalse(np.array_equal(res, np.zeros((20, 30))))
8585

8686
t = empty((20, 30), chunks=5)
@@ -91,7 +91,7 @@ def testEmptyExecution(self):
9191
t2 = empty_like(t)
9292
res = self.executor.execute_tensor(t2, concat=True)
9393
self.assertEqual(res[0].shape, (20, 30))
94-
self.assertTrue(res[0].dtype, np.int64)
94+
self.assertEqual(res[0].dtype, np.float64)
9595

9696
def testFullExecution(self):
9797
t = full((2, 2), 1, dtype='f4', chunks=1)
@@ -328,7 +328,7 @@ def testEyeExecution(self):
328328
t = eye(2, dtype=int)
329329

330330
res = self.executor.execute_tensor(t, concat=True)[0]
331-
self.assertEqual(res.dtype, np.int64)
331+
self.assertEqual(res.dtype, np.int_)
332332

333333
# test sparse
334334
t = eye(5, sparse=True, chunks=2)
@@ -410,7 +410,7 @@ def testLinspaceExecution(self):
410410
a = linspace(2.0, 9.0, num=11, chunks=3, dtype=int)
411411

412412
res = self.executor.execute_tensor(a, concat=True)[0]
413-
self.assertEqual(res.dtype, np.int64)
413+
self.assertEqual(res.dtype, np.int_)
414414

415415
def testMeshgridExecution(self):
416416
a = arange(5, chunks=2)

mars/tests/test_promise.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import time
1919
import unittest
2020
import weakref
21+
import sys
2122

2223
import gevent
2324

@@ -87,6 +88,7 @@ def _raise_exception(exc):
8788
raise exc
8889

8990

91+
@unittest.skipIf(sys.platform == 'win32', 'does not run in windows')
9092
class Test(unittest.TestCase):
9193
def testPromise(self):
9294
promises = weakref.WeakValueDictionary()

mars/web/tests/test_api.py

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,34 @@
1414
# limitations under the License.
1515

1616
import time
17+
import requests
18+
import json
19+
import unittest
20+
import mock
1721
import os
1822
import sys
1923
import signal
2024
import subprocess
21-
import unittest
2225

26+
import gevent
2327
import numpy as np
2428
from numpy.testing import assert_array_equal
25-
import gevent
26-
import requests
2729

28-
from mars.config import options
30+
2931
from mars import tensor as mt
32+
from mars.tensor.execution.core import Executor
33+
from mars.actors import create_actor_pool, new_client
3034
from mars.utils import get_next_port
31-
from mars.actors.core import new_client
32-
from mars.scheduler import KVStoreActor
35+
from mars.cluster_info import ClusterInfoActor
36+
from mars.scheduler import SessionManagerActor, KVStoreActor, ResourceActor
37+
from mars.scheduler.graph import GraphActor
38+
from mars.web import MarsWeb
3339
from mars.session import new_session
40+
from mars.serialize.dataserializer import dumps, loads
41+
from mars.config import options
3442

3543

44+
@unittest.skipIf(sys.platform == 'win32', 'does not run in windows')
3645
class Test(unittest.TestCase):
3746
@classmethod
3847
def setUpClass(cls):
@@ -179,3 +188,67 @@ def testApi(self):
179188
res = requests.get(service_ep + '/worker')
180189
self.assertEqual(res.status_code, 200)
181190

191+
192+
class TestWithMockServer(unittest.TestCase):
193+
def setUp(self):
194+
self._executor = Executor('numpy')
195+
196+
# create scheduler pool with needed actor
197+
scheduler_address = '127.0.0.1:' + str(get_next_port())
198+
pool = create_actor_pool(address=scheduler_address, n_process=1, backend='gevent')
199+
pool.create_actor(ClusterInfoActor, [scheduler_address], uid=ClusterInfoActor.default_name())
200+
pool.create_actor(ResourceActor, uid=ResourceActor.default_name())
201+
pool.create_actor(SessionManagerActor, uid=SessionManagerActor.default_name())
202+
self._kv_store_ref = pool.create_actor(KVStoreActor, uid=KVStoreActor.default_name())
203+
self._pool = pool
204+
205+
self.start_web(scheduler_address)
206+
207+
check_time = time.time()
208+
while True:
209+
if time.time() - check_time > 30:
210+
raise SystemError('Wait for service start timeout')
211+
try:
212+
resp = requests.get(self._service_ep + '/api', timeout=1)
213+
except (requests.ConnectionError, requests.Timeout):
214+
time.sleep(1)
215+
continue
216+
if resp.status_code >= 400:
217+
time.sleep(1)
218+
continue
219+
break
220+
221+
def tearDown(self):
222+
self._web.stop()
223+
self._pool.stop()
224+
225+
def start_web(self, scheduler_address):
226+
import gevent.monkey
227+
gevent.monkey.patch_all()
228+
229+
web_port = str(get_next_port())
230+
mars_web = MarsWeb(port=int(web_port), scheduler_ip=scheduler_address)
231+
mars_web.start()
232+
service_ep = 'http://127.0.0.1:' + web_port
233+
self._web = mars_web
234+
self._service_ep = service_ep
235+
236+
@mock.patch(GraphActor.__module__ + '.GraphActor.execute_graph')
237+
@mock.patch(GraphActor.__module__ + '.ResultReceiverActor.fetch_tensor')
238+
def testApi(self, mock_fetch_tensor, _):
239+
with new_session(self._service_ep) as sess:
240+
self._kv_store_ref.write('/workers/meta/%s' % 'mock_endpoint', 'mock_meta')
241+
self.assertEqual(sess.count_workers(), 1)
242+
243+
a = mt.ones((100, 100), chunks=30)
244+
b = mt.ones((100, 100), chunks=30)
245+
c = a.dot(b)
246+
graph_key = sess.run(c, timeout=120, wait=False)
247+
self._kv_store_ref.write('/sessions/%s/graph/%s/state' % (sess.session_id, graph_key), 'SUCCEEDED')
248+
graph_url = '%s/api/session/%s/graph/%s' % (self._service_ep, sess.session_id, graph_key)
249+
graph_state = json.loads(requests.get(graph_url).text)
250+
self.assertEqual(graph_state['state'], 'success')
251+
mock_fetch_tensor.return_value = dumps(self._executor.execute_tensor(c, concat=True)[0])
252+
data_url = graph_url + '/data/' + c.key
253+
data = loads(requests.get(data_url).content)
254+
assert_array_equal(data, np.ones((100, 100)) * 100)

0 commit comments

Comments
 (0)