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

Add class call to write_output(). #54 #55

Merged
merged 2 commits into from Apr 25, 2019

Conversation

Projects
None yet
3 participants
@greebie
Copy link
Collaborator

commented Apr 24, 2019

This change adds the class call (nb.) to write_output() and adds the new version of au-notebook to requirements.txt.

To test:

spin the notebook
remove comment from this line in cell 6.
# nb.write_output(filename, year_results)

Run the notebook.

(Again, if you already have the notebook running, you will need to restart and run all).

@ruebot
Copy link
Member

left a comment

Update the README with the correct version number for au_notebook.

@ruebot

ruebot approved these changes Apr 24, 2019

@ianmilligan1

This comment has been minimized.

Copy link
Member

commented Apr 25, 2019

I can't get this to work.

Am now on the right version of au-notebook

Requirement already satisfied: au-notebook==0.0.3 in /Users/ianmilligan1/anaconda/lib/python3.5/site-packages (from -r requirements.txt (line 1)) (0.0.3)

But

nb.write_output(filename, year_results)

still leading to

Error writing the file.

This is out of the box on MacOS, running pip install -r requirements.txt and then jupyter notebook.

@ianmilligan1

This comment has been minimized.

Copy link
Member

commented Apr 25, 2019

Did a bit more testing.

If I set up the function locally i.e.

def write_output2(self, stdout, results):
        """ Writes results to file.
        :param stdout: Filepath for file.
        :param results: A list of results.
        :return: None.
        """
        try:
            with open(stdout, "w") as output:
                for value in results:
                    output.write(str(value))
        except Exception as exp:
            print("Error writing the file.")

then running

write_output2(filename, year_results)

gives me this error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-23-f3735c684425> in <module>()
     13 ## or nb.output_filename (set in the User Configuration section).
     14 
---> 15 write_output2(filename, year_results)

TypeError: write_output2() missing 1 required positional argument: 'results'

Is it working on your end, @greebie ?

@ianmilligan1

This comment has been minimized.

Copy link
Member

commented Apr 25, 2019

I should note that it works with Binder.. so something a bit funky with running it locally here. I may also be missing something obvious. 😄

@ruebot

This comment has been minimized.

Copy link
Member

commented Apr 25, 2019

Weird. Can you try pip install --upgrade aut-notebook before you fire up the notebook, and see if that works?

It's working for me locally, and I just fired it up with the Docker build too, and it ran fine.

Screenshot from 2019-04-24 23-45-07

Screenshot from 2019-04-24 23-42-15

Screenshot from 2019-04-24 23-42-25

@greebie

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 25, 2019

Not sure why it should not work. I think the problem with write_output2 is that you do not need 'self' in a simple function that is not part of a class.

Can you do a 'restart and run all' and try again? That always messes me up. But yeah I had the same result as Nick.

@ianmilligan1
Copy link
Member

left a comment

🤦‍♂️ I had to manually go in and delete the earlier libraries, and when it was all fresh it worked. Thanks for your help @greebie and @ruebot.

@ianmilligan1 ianmilligan1 merged commit 256db8e into master Apr 25, 2019

1 check passed

ci/dockercloud Your tests passed in Docker Cloud
Details

@ianmilligan1 ianmilligan1 deleted the issue-54 branch Apr 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.