philcowans / fcli

A command line Mastodon / Fediverse client
MIT License
7 stars 2 forks source link

New user initialisation issues #14

Open andypiper opened 1 month ago

andypiper commented 1 month ago

I've created all of the directories and files (I think).

Python 3.11 on macOS:

$ python -m fcli-client
Welcome to fcli 1.0.0 - (c) 2023-2024 Phil Cowans

Released under the MIT license, see LICENSE for details
More info at https://github.com/philcowans/fcli

Updating stats ... Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/andypiper/Development/third-party/fcli/fcli-client/__main__.py", line 182, in <module>
    Ratings().account_summary().write_lists()
  File "/Users/andypiper/Development/third-party/fcli/fcli-client/analytics.py", line 84, in write_lists
    summary = self.to_df()
              ^^^^^^^^^^^^
  File "/Users/andypiper/Development/third-party/fcli/fcli-client/analytics.py", line 45, in to_df
    (self._all_posts['Status'] == 'interesting')
     ~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/andypiper/.pyenv/versions/3.11.6/lib/python3.11/site-packages/pandas/core/frame.py", line 3893, in __getitem__
    indexer = self.columns.get_loc(key)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andypiper/.pyenv/versions/3.11.6/lib/python3.11/site-packages/pandas/core/indexes/range.py", line 418, in get_loc
    raise KeyError(key)
KeyError: 'Status'
andypiper commented 1 month ago

Looks like this is due to the state not existing yet. Commenting out line 182 where it updates the stats, then causes it to break with:

FileNotFoundError: [Errno 2] No such file or directory: '/Users/andypiper/.fcli/state.json'

Working on understanding what that should look like...

andypiper commented 1 month ago

OK, wrote

{"max_id": 0, "max_notification_id": 0, "token": ""}

into the state file and we are off to the races... got prompted to authenticate...

Notification summary: favourite (22), follow (7), reblog (1), mention (10)

Press enter to start review
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/andypiper/Development/third-party/fcli/fcli-client/__main__.py", line 208, in <module>
    post_list.plan()
  File "/Users/andypiper/Development/third-party/fcli/fcli-client/post_list.py", line 65, in plan
    self._files = get_filenames_with_algorithm(algorithm, all_files)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andypiper/Development/third-party/fcli/fcli-client/post_list.py", line 20, in get_filenames_with_algorithm
    with open(algorithm.hqa_filename or hqa_filename(), encoding='utf-8') as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/andypiper/.fcli/high_quality_accounts.txt'
andypiper commented 1 month ago

and then

$ touch /Users/andypiper/.fcli/high_quality_accounts.txt

[re-edit __main.py__ to add line 182 back in]

$ python -m fcli-client                                                                                                                      

Welcome to fcli 1.0.0 - (c) 2023-2024 Phil Cowans

Released under the MIT license, see LICENSE for details
More info at https://github.com/philcowans/fcli

Updating stats ... done.
Authenticating ... done.
Synchronising following list ... done.
Posting queued statuses ... done.
Fetching new posts ... Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/andypiper/Development/third-party/fcli/fcli-client/__main__.py", line 206, in <module>
    token = _do_sync()
            ^^^^^^^^^^
  File "/Users/andypiper/Development/third-party/fcli/fcli-client/__main__.py", line 130, in _do_sync
    response_id = response["id"]
                  ~~~~~~~~^^^^^^
TypeError: string indices must be integers, not 'str'
andypiper commented 1 month ago

... third time lucky on running, but:

Completed sync.

Notification summary: favourite (43), follow (8), mention (19), reblog (10)

Press enter to start review
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/andypiper/Development/third-party/fcli/fcli-client/__main__.py", line 209, in <module>
    post_list.plan()
  File "/Users/andypiper/Development/third-party/fcli/fcli-client/post_list.py", line 65, in plan
    self._files = get_filenames_with_algorithm(algorithm, all_files)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andypiper/Development/third-party/fcli/fcli-client/post_list.py", line 23, in get_filenames_with_algorithm
    files = list(np.random.choice([
                 ^^^^^^^^^^^^^^^^^^
  File "numpy/random/mtrand.pyx", line 950, in numpy.random.mtrand.RandomState.choice
ValueError: 'a' cannot be empty unless no samples are taken

Line 23-28 of post_list.py:

    files = list(np.random.choice([
        file[0]
        for file in all_files
        if (file[1].username() not in ['benb', 'HamiltonsLive'])
        and (file[1].full_account_name() in hqas)
    ], size=algorithm.non_lqa_count, replace=False))

This seems very specific to an individual user workflow?

qmacro commented 1 month ago

FWIW I get this exact same error.

(I'm setting up and running in the context of a Docker container image, defined via https://github.com/philcowans/fcli/pull/15/files, which has Python 3.12.3)

andypiper commented 1 month ago

I've just reproduced the same series of things on Fedora 40 with Python 3.12. Hitting the wall with

Posting queued statuses ... done.
Fetching new posts ... Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/andypiper/Development/third-party/fcli/fcli-client/__main__.py", line 184, in <module>
    token = _do_sync()
            ^^^^^^^^^^
  File "/home/andypiper/Development/third-party/fcli/fcli-client/__main__.py", line 122, in _do_sync
    response_id = response['id']
                  ~~~~~~~~^^^^^^
TypeError: string indices must be integers, not 'str'

I did a bit of debugging here and I'm not entirely certain whether the ~/.fcli/high_quality_accounts.txt (and LQA) file needs to exist and be populated first, or how to do so.