Skip to content

support unversioned boards - #230

Merged
isabelizimm merged 10 commits into
mainfrom
unversioned-boards
Apr 16, 2024
Merged

isabelizimm merged 10 commits into
mainfrom
unversioned-boards

Conversation

@isabelizimm

Copy link
Copy Markdown
Collaborator

closes #228

Comment thread pins/boards.py Outdated
if not self.pin_exists(name):
raise PinsError("Cannot check version, since pin %s does not exist" % name)

if isinstance(self, BoardRsConnect):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

related to #229, Connect actually needs this to be True 😩

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Darn.

It might make it a bit less onerous to write

detail = isinstance(self, BoardRsConnect)

instead of the assignment inside a block.

Comment thread pins/boards.py

return meta

def _create_meta(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

splitting this out so I can use _create_meta for Connect, without running the version_setup. Connect needs its own flavor since you cannot delete the latest pin. This causes the following behavior:

Most boards:
make metadata -> check and delete old versions for unversioned -> write new pin

Connect:
make metadata -> write new pin -> check and delete old versions for unversioned

Comment thread pins/boards.py
if versioned is None:
versioned = True if n_versions_before > 1 else self.versioned
if versioned is False and n_versions_before > 1:
raise PinsVersionError(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

trying to fail fast if we can't write the pin anyway

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems like the effects of this are...

  • upside: it will take less time on connect to raise a PinsVersionError.
  • downside: every successful use of pin_write will be slower.

I think it's okay for failing cases to run slightly slower, since they should be the exception, not the norm. I would remove, so the normal cases don't eat the overhead of running these calls multiple times. (But also might be misunderstanding this code).

@isabelizimm isabelizimm Apr 16, 2024 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated-- then was reminded the Posit Connect cannot delete the latest pin 😅 so there is a need to do these calls before a pin is written. Instead, I'll try to do an API call as a last resort, and only if we're pretty sure there needs to be some handling for unversioned boards/pins.

Comment thread pins/tests/test_boards.py
board.pin_read("test_pin")


# pin_write with unversioned boards ===========================================

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

testing the following:

  • if a BOARD is unversioned

    • first write: okay
    • following writes:
      • if PIN is versioned: keep all copies
      • if PIN is unversioned: keep latest copy
      • if PIN is not specified: keep latest copy
  • if a BOARD is versioned

    • first write: okay
    • following writes:
      • if PIN is versioned: keep all copies (as normal)
      • if PIN is unversioned: raise error
      • if PIN is not specified: keep all copies (as normal)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this note, it's super handy!

@machow machow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left a couple quick notes, but overall looks great! Feel free to incorporate or punt and do w/e is useful! (Feel free to merge if any changes don't seem like they need more review)

Comment thread pins/tests/test_boards.py Outdated

def test_board_versioned_pin_write_unversioned(board):
# should fall back to the versioned setting of the board
board.pin_write({"a": 1}, "test_pin", type="json", versioned=False)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you pin_write(..., versioned=False) a second time, will it still just be 1 version? It feels like that might be a critical piece of this test (since just 1 write should always be 1 version, regardless of versioned?).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ah, yeah I don't think this test is meaningful, so I pulled it. The intention was that 1-write pins don't error, etc, but it's true that is tested elsewhere!

Comment thread pins/boards.py
if versioned is None:
versioned = True if n_versions_before > 1 else self.versioned
if versioned is False and n_versions_before > 1:
raise PinsVersionError(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems like the effects of this are...

  • upside: it will take less time on connect to raise a PinsVersionError.
  • downside: every successful use of pin_write will be slower.

I think it's okay for failing cases to run slightly slower, since they should be the exception, not the norm. I would remove, so the normal cases don't eat the overhead of running these calls multiple times. (But also might be misunderstanding this code).

Comment thread pins/tests/test_boards.py
board.pin_read("test_pin")


# pin_write with unversioned boards ===========================================

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this note, it's super handy!

This branch was successfully deployed

1 active deployment
pr-230 — 41e3daa6 Deployed Apr 16, 2024 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants