Skip to content

Fix: __future__ imports must occur at the beginning of the file#5

Open
IamJeffG wants to merge 1 commit intoclearml:masterfrom
IamJeffG:no_future_imports
Open

Fix: __future__ imports must occur at the beginning of the file#5
IamJeffG wants to merge 1 commit intoclearml:masterfrom
IamJeffG:no_future_imports

Conversation

@IamJeffG
Copy link

@IamJeffG IamJeffG commented Jan 8, 2025

This PR fixes the keras_mmist.py example script so it may be run as per this example in ClearML's docs.

Before this PR, running that example would fail with

Starting Task Execution:
  File "/root/.clearml/venvs-builds/3.10/task_repository/events.git/webinar-0620/keras_mnist.py", line 5
    from __future__ import print_function
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: from __future__ imports must occur at the beginning of the file

The clearml-agent had pushed down from __future__ import print_function from line 1 to line 5, by having prefixed the following lines to the top of the script:

try: from allegroai import Task
except ImportError: from clearml import Task
(__name__ != "__main__") or Task.init()

I don't know if there's a better solution to this problem, but this one feels pretty safe as Python 2 is on its way out.

What I'm not doing: Similar modifications to scripts in the odsc20-east folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant