Skip to content

MAINT Configure Windows CI using AppVeyor #258

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

Merged
merged 21 commits into from
Jun 14, 2018
Merged

MAINT Configure Windows CI using AppVeyor #258

merged 21 commits into from
Jun 14, 2018

Conversation

jacksonllee
Copy link
Contributor

IT support has turned on AppVeyor for CI in Windows. This PR configures that, based on what we already have for Circle CI.

Resolves #10.

by checking just whether or not poller is called.
Asserting a specific call count for a given sleep time
is not practical, because of different execution/testing environments
(Circle CI versus AppVeyor, for example).
Because polling_interval is 0.01, setting sleep time of 0.02s
should (hopefully) be long enough to register at least 1
poller call.
feather-format depends on pyarrow, which does not have
Windows packages for python version < 3.5.
See https://arrow.apache.org/docs/python/install.html
polling_interval=POLL_INTERVAL)
result = result.result()
cls.export_url = result['output'][0]['path']
assert result.state == 'succeeded'

cls.export_job_id = result.sql_id

@pytest.mark.skipif(sys.platform.startswith('win')) # TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you fix this test? Does it still need to be skipped in Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test isn't fixed yet, and I plan to. I threw in this skipif thing to suppress for something else. We're very close to getting the whole thing working. I'll tag you when the PR is ready fo review.

Copy link
Contributor

@keithing keithing Jun 11, 2018

Choose a reason for hiding this comment

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

Sounds good. Great work on this so far!

@jacksonllee jacksonllee added this to the Next Version milestone Jun 11, 2018
The archive name is a member file inside a zip file.
It'd seem more reasonable to have it different than
the zip file name.
fname = os.path.join(temp_dir, str(uuid.uuid4()))
with zipfile.ZipFile(fname, 'w', zipfile.ZIP_DEFLATED) as zip_file:
archive_name = str(uuid.uuid4())
zip_file.writestr(archive_name, 'a,b,c\n1,2,3')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

archive_name should be its own distinct filename rather than being the same as the zipf file's filename. Also, using the zip file's filename failed this test because apparently the ZipFile object normalizes backslashes into forward slashes in filenames internally, which caused test failures like this.

Copy link
Contributor

@keithing keithing Jun 12, 2018

Choose a reason for hiding this comment

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

So this means that you can't use archive_name = os.path.join(temp_dir, str(uuid.uiid4()))? If you run the tests locally, won't this litter your folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just run the test suite locally to verify that no random temp files are created. zip_file.writestr(archive_name, ...) writes a new member file named archive_name to zip_file which is the already instantiated temp zip file; it doesn't mean creating a file called archive_name at the current directory.

time.sleep(0.015)
assert poller.call_count == 1
time.sleep(0.02)
assert poller.call_count > 0
Copy link
Contributor Author

@jacksonllee jacksonllee Jun 12, 2018

Choose a reason for hiding this comment

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

Because now we have different execution environments for builds (Circle CI versus AppVeyor), this test has become a little unstable (see this test failure due to such indeterminancy). Given polling_internal=0.01 (set just a few lines above, via PollableResult), sleeping 0.02s gives a little more time for at least one poller call count.

Choose a reason for hiding this comment

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

It was a little unstable in the Linux tests, to be honest. Hopefully this change makes life better for everyone. Thank you!

@@ -7,7 +7,7 @@ vcrpy>=1.11.0,<=1.11.99
vcrpy-unittest==0.1.6
sphinx_rtd_theme>=0.2.4,<1.0.0
numpydoc>=0.7.0,<1.0.0
feather-format
feather-format; sys_platform != 'win32' or python_version >= '3.5'
Copy link
Contributor Author

@jacksonllee jacksonllee Jun 12, 2018

Choose a reason for hiding this comment

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

feather-format depends on pyarrow, which doesn't have a Windows installer for Python < 3.5; see here. Not having feather-format installed skips one test only, which I think is fine (and we are running this test for Python >= 3.5 on Windows anyway).

@jacksonllee
Copy link
Contributor Author

@keithing I've defeated AppVeyor! Good news is that only changes in tests are needed for Windows compatibility. It's mostly about not using tempfile.NamedTemporaryFile. I've left comments for other changes. This PR is ready for review.

@jacksonllee jacksonllee requested a review from keithing June 12, 2018 19:46
@jacksonllee jacksonllee changed the title WIP MAINT Configure Windows CI using AppVeyor MAINT Configure Windows CI using AppVeyor Jun 12, 2018
keithing
keithing previously approved these changes Jun 12, 2018
Copy link
Contributor

@keithing keithing left a comment

Choose a reason for hiding this comment

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

LGTM! @stephen-hoover, you on board for adding Windows tests?

stephen-hoover
stephen-hoover previously approved these changes Jun 12, 2018
Copy link

@stephen-hoover stephen-hoover left a comment

Choose a reason for hiding this comment

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

This is great! I left a couple of comments in places where I think the code could be made a bit cleaner by fully embracing the temporary directory, but I'm happy merging this as is.

with tempfile.NamedTemporaryFile() as tempfname:
fname = tempfname.name
with TemporaryDirectory() as temp_dir:
fname = os.path.join(temp_dir, str(uuid.uuid4()))

Choose a reason for hiding this comment

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

You don't need a uuid for anything created in a temporary directory -- the file will vanish as soon as you exit the context, and I don't see a danger of a name collision inside this test.

with open(fname, 'w+b') as tmp:
tmp.write(b'a,b,c\n1,2,3')
tmp.flush()
tmp.seek(0)

Choose a reason for hiding this comment

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

I would exit the write context and re-open the file in a new with open(...) context here. The seek(0) was so that we could use a temporary file which disappeared when closed.

fname = os.path.join(temp_dir, str(uuid.uuid4()))
with open(fname, 'w+b') as tmp:
tmp.write(b'a,b,c\n1,2,3')
tmp.flush()

Choose a reason for hiding this comment

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

This should be unnecessary now that we're using a write context manager, but it also won't hurt anything.

time.sleep(0.015)
assert poller.call_count == 1
time.sleep(0.02)
assert poller.call_count > 0

Choose a reason for hiding this comment

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

It was a little unstable in the Linux tests, to be honest. Hopefully this change makes life better for everyone. Thank you!

@jacksonllee
Copy link
Contributor Author

Hmm, I've made changes according to Stephen's suggestions, but now the builds fail for Python 3.5 and 3.6 (for both Linux and Windows builds). For these two Python versions, it looks like we're using whatever the latest version of pandas is available from PyPI. pandas v0.23.1 was released just 9 hours ago -- either it is broken, or at least it breaks our builds.

Indeed, all builds passed with pandas v0.23.0; see the successful Linux builds triggered by 9fbb4be committed yesterday.

Back to the most recent build failures for Python 3.5 and 3.6, it looks like when _stash_dataframe_as_csv from civis/ml/_model.py calls df.to_csv, the under-the-hood pandas's CSVFormatter object calls the save method, which triggers AttributeError: '_io.TextIOWrapper' object has no attribute 'getvalue'.

I'll come back to this PR later in the day.

@stephen-hoover
Copy link

This test failure was caused by pandas-dev/pandas#21300 . I'm not sure if it represents a bug on our end or just a change in the parameter options available for to_csv. I think we should fix _stash_dataframe_as_csv in a different PR so that it works with the latest version of pandas.

@jacksonllee
Copy link
Contributor Author

#259 fixes _stash_dataframe_as_csv. When that PR is merged, I'll rebase here.

@jacksonllee
Copy link
Contributor Author

I'm sorting out the repo / AppVeyor settings with IT support. Sit tight, everyone.

@jacksonllee jacksonllee assigned jacksonllee and unassigned keithing Jun 13, 2018
@jacksonllee
Copy link
Contributor Author

We're all set. All builds for both Linux and Windows have passed. This PR is ready for review again.

Copy link
Contributor

@keithing keithing left a comment

Choose a reason for hiding this comment

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

This is great. Thanks for sticking with this. LGTM.

Copy link

@stephen-hoover stephen-hoover left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for doing this!

@jacksonllee jacksonllee merged commit c220a52 into civisanalytics:master Jun 14, 2018
@jacksonllee jacksonllee deleted the set-up-windows-continuous-integration branch June 14, 2018 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants