Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

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

Merged
merged 2 commits into from
Apr 25, 2019
Merged

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

merged 2 commits into from
Apr 25, 2019

Conversation

greebie
Copy link
Collaborator

@greebie greebie 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).

Copy link
Member

@ruebot ruebot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the README with the correct version number for au_notebook.

@ianmilligan1
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

ruebot 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
Copy link
Collaborator Author

greebie 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.

Copy link
Member

@ianmilligan1 ianmilligan1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ 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
@ianmilligan1 ianmilligan1 deleted the issue-54 branch April 25, 2019 11:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants