-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat: improve operation messages and make them stateful #9245
base: main
Are you sure you want to change the base?
Conversation
@@ -351,7 +351,7 @@ def _write_lock_file(self, repo: LockfileRepository, force: bool = False) -> Non | |||
|
|||
if updated_lock: | |||
self._io.write_line("") | |||
self._io.write_line("<info>Writing lock file</>") | |||
self._io.write_line("<info>Lock file written</>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have this stateful as well? Like, Writing lock file
changing to Lock file written
once the operation is done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well then, I guess that a new IO section would be needed and the
poetry/src/poetry/packages/locker.py
Lines 255 to 257 in fe9f85b
if self._should_write(lock): | |
self._write_lock_data(lock) | |
return True |
snippet would probably have to be rewritten to
if self._should_write(lock):
section = ...
section.write_line("<info>Writing lock file</>")
self._write_lock_data(lock)
section.write_line("<info>Lock file written</>") # or <success>Lock file written</>
return True
Is it worth the cost? It would require introducing a side effect in _write_lock_file
or adding some extra logic to set_lock_data
. IO writes are quite fast in contrary to installation operations; the only advantage it would bring is that it could inform about a potentially (but very rarely) erroneous action taken (in case the write fails) useful as a context for a traceback following the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then maybe we could do something like Writing lock file... Done.
where Done.
appears after the operation is finished?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then maybe we could do something like
Writing lock file... Done.
whereDone.
appears after the operation is finished?
I think that would be inconsistent with the rest of the UI. Also, would it address the issue with additional logic/necessity of introducing new _write_lock_file
side effects somehow?
bf89285
to
e80c1e8
Compare
The lock file message is triggered *after* writing the lock file. This revision now makes the message convey truth about what Poetry is/was really doing.
…after installation
e80c1e8
to
c3648d9
Compare
Pull Request Check List
This PR proposes more meaningful messages on installation operations:
poetry/src/poetry/installation/installer.py
Lines 350 to 354 in fe9f85b
one could easily observe that the "Writing lock file" message is written if
updated_lock
is truthy—and can only be after actually completing writing the lock file:poetry/src/poetry/packages/locker.py
Lines 251 to 259 in fe9f85b
poetry/src/poetry/packages/locker.py
Lines 309 to 313 in fe9f85b
Where
TOMLFile.write()
atomically writes to the file.Operation
objects were partially stateful (e.g. held theskipped
attribute) and now are fully stateful (store the information about whether they are in thedone
,warning
orerror
state). Different attribute names ideas are welcome.Executor.get_operation_message()
was deprecated and polymorphism was utilized in lieu of it. The new implementation was made to be 100% equivalent except that after the relevant operations finish, their messages use past tense in ANSI supporting cases–instead of freezing at "Downgrading" ifUpdate(...).done
isTrue
, "Downgraded" is written eventually, etc.Before this can eventually be merged, we need a new GIF in the Poetry readme. @neersighted could you help with that?