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

Error launching TensorBoard on Windows due to %s strftime specifier #1895

Closed
Origamichen opened this issue Feb 26, 2019 · 5 comments
Closed

Comments

@Origamichen
Copy link

TensorBoard version: 1.13.0
Tensorflow version: tensorflow-gpu 1.13.0rc2
OS Platform and version: Windows10 1803
Python version: 3.7

Hi,
Here's a minor error occurs when I run tensorboard 1.13.0. It is fixed by changing line 50 in tensorboard/manager.py
serialize=lambda dt: int(dt.strftime("%s")), to serialize=lambda dt: int(dt.strftime("%S")),
The "%s" is changed to "%S".

Traceback (most recent call last):
File "d:\programme\anaconda\Lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "d:\programme\anaconda\Lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "D:\Workspace\Python\TensorflowVenv\TfEnv\Scripts\tensorboard.exe_main
.py", line 9, in
File "d:\workspace\python\tensorflowvenv\tfenv\lib\site-packages\tensorboard\main.py", line 57, in run_main
app.run(tensorboard.main, flags_parser=tensorboard.configure)
File "d:\workspace\python\tensorflowvenv\tfenv\lib\site-packages\absl\app.py", line 300, in run
_run_main(main, args)
File "d:\workspace\python\tensorflowvenv\tfenv\lib\site-packages\absl\app.py", line 251, in _run_main
sys.exit(main(argv))
File "d:\workspace\python\tensorflowvenv\tfenv\lib\site-packages\tensorboard\program.py", line 228, in main
self._register_info(server)
File "d:\workspace\python\tensorflowvenv\tfenv\lib\site-packages\tensorboard\program.py", line 274, in _register_info
manager.write_info_file(info)
File "d:\workspace\python\tensorflowvenv\tfenv\lib\site-packages\tensorboard\manager.py", line 268, in write_info_file
payload = "%s\n" % _info_to_string(tensorboard_info)
File "d:\workspace\python\tensorflowvenv\tfenv\lib\site-packages\tensorboard\manager.py", line 128, in _info_to_string
for k in _TENSORBOARD_INFO_FIELDS
File "d:\workspace\python\tensorflowvenv\tfenv\lib\site-packages\tensorboard\manager.py", line 128, in
for k in _TENSORBOARD_INFO_FIELDS
File "d:\workspace\python\tensorflowvenv\tfenv\lib\site-packages\tensorboard\manager.py", line 50, in
serialize=lambda dt: int(dt.strftime("%s")),
ValueError: Invalid format string

@xieyonglu
Copy link

Find the manger.py file in directory ..\Lib\site-packages\tensorboard,and modify dt.strftime("%s") to dt.strftime("%S")

@stephanwlee
Copy link
Contributor

@wchargin can you please TAL? It seems like something we should be able to fix.

@nfelt
Copy link
Contributor

nfelt commented Feb 26, 2019

Hm, it looks like %s isn't actually cross-platform :( https://stackoverflow.com/a/11743262/1179226

The recommended workarounds are truly sad, but I guess we should change it to one of those.

FWIW, changing to %S (number of seconds, 0-59) is not a working replacement. @Origamichen @xieyonglu If you want a temporary workaround it's better to replace it with dt.strftime("0") which at least will consistently be the start of the unix Epoch instead of somewhere between 0-60 seconds after it.

wchargin added a commit that referenced this issue Feb 26, 2019
Summary:
Fixes #1895 by replacing the (apparently unportable) `%s` format
specifier with an explicit subtraction from epoch.

Test Plan:
I don’t have easy access to a Windows machine with a Bazel/TensorBoard
setup, but I verified that this expression can be evaluated by itself:

```
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import datetime
>>> dt = datetime.datetime.now()
>>> dt.strftime("%s")
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    dt.strftime("%s")
ValueError: Invalid format string
>>> int((dt - datetime.datetime.fromtimestamp(0)).total_seconds())
1551203889
```

Running `git grep strftime.*%s` returns no matches as of this commit.

wchargin-branch: windows-strftime
@wchargin wchargin changed the title Error when running tensorboard 1.13.0 Error launching TensorBoard on Windows due to %s strftime specifier Feb 26, 2019
wchargin added a commit that referenced this issue Feb 26, 2019
Summary:
Fixes #1895 by replacing the (apparently unportable) `%s` format
specifier with an explicit subtraction from epoch.

Test Plan:
I don’t have easy access to a Windows machine with a Bazel/TensorBoard
setup, but I verified that this expression can be evaluated by itself:

```
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import datetime
>>> dt = datetime.datetime.now()
>>> dt.strftime("%s")
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    dt.strftime("%s")
ValueError: Invalid format string
>>> int((dt - datetime.datetime.fromtimestamp(0)).total_seconds())
1551203889
```

Running `git grep strftime.*%s` returns no matches as of this commit.

wchargin-branch: windows-strftime
@israfila3
Copy link

you can change the ("strftime("%s") to strftime("%S") ==> %s to %S") on line 50 in (site-packages\tensorboard\manager.py )

@wchargin
Copy link
Contributor

wchargin commented Mar 4, 2019

@israfila3: As noted above, that is not a sound replacement. Please see
@nickfelt’s comment if you want an immediate workaround. We plan to
release a TensorBoard 1.13.1 patch shortly (probably today) that will
contain the fix for this.

wchargin added a commit to wchargin/tensorboard that referenced this issue Mar 5, 2019
Summary:
Fixes tensorflow#1895 by replacing the (apparently unportable) `%s` format
specifier with an explicit subtraction from epoch.

Test Plan:
I don’t have easy access to a Windows machine with a Bazel/TensorBoard
setup, but I verified that this expression can be evaluated by itself:

```
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import datetime
>>> dt = datetime.datetime.now()
>>> dt.strftime("%s")
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    dt.strftime("%s")
ValueError: Invalid format string
>>> int((dt - datetime.datetime.fromtimestamp(0)).total_seconds())
1551203889
```

Running `git grep strftime.*%s` returns no matches as of this commit.

wchargin-branch: windows-strftime
wchargin added a commit that referenced this issue Mar 6, 2019
Summary:
Fixes #1895 by replacing the (apparently unportable) `%s` format
specifier with an explicit subtraction from epoch.

Test Plan:
I don’t have easy access to a Windows machine with a Bazel/TensorBoard
setup, but I verified that this expression can be evaluated by itself:

```
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import datetime
>>> dt = datetime.datetime.now()
>>> dt.strftime("%s")
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    dt.strftime("%s")
ValueError: Invalid format string
>>> int((dt - datetime.datetime.fromtimestamp(0)).total_seconds())
1551203889
```

Running `git grep strftime.*%s` returns no matches as of this commit.

wchargin-branch: windows-strftime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants