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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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