Skip to content

Commit 81af8a3

Browse files
committed
Closing temporary file to avoid double open bug
1 parent d20549e commit 81af8a3

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
### Added
99

10+
## [1.6.1] - 2022-8-31
11+
12+
### Fixed
13+
- Bug in new simulation upload on Windows machines.
14+
1015
## [1.6.0] - 2022-8-29
1116

1217
### Added
@@ -389,7 +394,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
389394
- Job and Batch classes for better simulation handling (eventually to fully replace webapi functions).
390395
- A large number of small improvements and bug fixes.
391396

392-
[Unreleased]: https://github.com/flexcompute/tidy3d/compare/v1.6.0...develop
397+
[Unreleased]: https://github.com/flexcompute/tidy3d/compare/v1.6.1...develop
398+
[1.6.0]: https://github.com/flexcompute/tidy3d/compare/v1.6.0...v1.6.1
393399
[1.6.0]: https://github.com/flexcompute/tidy3d/compare/v1.5.0...v1.6.0
394400
[1.5.0]: https://github.com/flexcompute/tidy3d/compare/v1.4.1...v1.5.0
395401
[1.4.1]: https://github.com/flexcompute/tidy3d/compare/v1.4.0...v1.4.1

tidy3d/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Defines the front end version of tidy3d"""
22

3-
__version__ = "1.6.0"
3+
__version__ = "1.6.1"

tidy3d/web/webapi.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,17 @@ def upload( # pylint:disable=too-many-locals,too-many-arguments
119119
# upload the file to s3
120120
log.debug("Uploading the json file")
121121

122-
with tempfile.NamedTemporaryFile() as data_file:
123-
# pylint:disable=protected-access
124-
json_string = simulation._json_string(data_file=data_file.name)
125-
if data_file.name in json_string:
126-
# Upload the extra data file if needed
127-
json_string.replace(data_file.name, DATA_FILE_NAME)
128-
upload_file(task_id, data_file.name, DATA_FILE_NAME)
129-
upload_string(task_id, json_string, SIM_FILE_NAME)
122+
# pylint:disable=consider-using-with
123+
data_file = tempfile.NamedTemporaryFile()
124+
# data_file will be reopened and closed in _json_string
125+
data_file.close()
126+
# pylint:disable=protected-access
127+
json_string = simulation._json_string(data_file=data_file.name)
128+
if data_file.name in json_string:
129+
# Upload the extra data file if needed
130+
json_string.replace(data_file.name, DATA_FILE_NAME)
131+
upload_file(task_id, data_file.name, DATA_FILE_NAME)
132+
upload_string(task_id, json_string, SIM_FILE_NAME)
130133

131134
# log the url for the task in the web UI
132135
log.debug(f"{DEFAULT_CONFIG.website_endpoint}/folders/{folder.projectId}/tasks/{task_id}")

0 commit comments

Comments
 (0)