From d4524818990cfe9b54bedf48b72e440b16394417 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Thu, 9 Jan 2025 18:34:24 +0530 Subject: [PATCH 1/3] show "Public" visibility for already public published runs in team workspace selectively enables showing "Public" visibility for public examples --- daras_ai_v2/base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/daras_ai_v2/base.py b/daras_ai_v2/base.py index e07a1bd9f..7a7b19112 100644 --- a/daras_ai_v2/base.py +++ b/daras_ai_v2/base.py @@ -560,6 +560,10 @@ def _render_share_modal(self, dialog: gui.AlertDialogRef): for enum in PublishedRunVisibility.choices_for_workspace( self.current_pr.workspace ) + } | { + str(self.current_pr.visibility): PublishedRunVisibility( + self.current_pr.visibility + ).help_text(self.current_pr.workspace) } published_run_visibility = PublishedRunVisibility( int( From 88739d3b10463bbd404cf8eef20a7b27bc3bf7e6 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Thu, 9 Jan 2025 18:53:02 +0530 Subject: [PATCH 2/3] refactor to not repeat visibility.help_text() logic --- daras_ai_v2/base.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/daras_ai_v2/base.py b/daras_ai_v2/base.py index 7a7b19112..02167d0f6 100644 --- a/daras_ai_v2/base.py +++ b/daras_ai_v2/base.py @@ -557,13 +557,12 @@ def _render_share_modal(self, dialog: gui.AlertDialogRef): options = { str(enum.value): enum.help_text(self.current_pr.workspace) - for enum in PublishedRunVisibility.choices_for_workspace( - self.current_pr.workspace - ) - } | { - str(self.current_pr.visibility): PublishedRunVisibility( - self.current_pr.visibility - ).help_text(self.current_pr.workspace) + for enum in [ + *PublishedRunVisibility.choices_for_workspace( + self.current_pr.workspace + ), + PublishedRunVisibility(self.current_pr.visibility), + ] } published_run_visibility = PublishedRunVisibility( int( From 60ad815b9d5415e7f763ef555c1c1c19c2ebf581 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:13:54 +0530 Subject: [PATCH 3/3] swap PublishedRunVisibility.choices_for_workspace for PublishedRunVisibility.choices_for_pr --- bots/models.py | 14 ++++++++------ daras_ai_v2/base.py | 7 +------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/bots/models.py b/bots/models.py index 31ee78cf5..3e1a61dbf 100644 --- a/bots/models.py +++ b/bots/models.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import datetime import typing from multiprocessing.pool import ThreadPool @@ -40,14 +42,14 @@ class PublishedRunVisibility(models.IntegerChoices): INTERNAL = 3 @classmethod - def choices_for_workspace( - cls, workspace: typing.Optional["Workspace"] - ) -> typing.Iterable["PublishedRunVisibility"]: - if not workspace or workspace.is_personal: - return [cls.UNLISTED, cls.PUBLIC] + def choices_for_pr( + cls, pr: PublishedRun + ) -> typing.Iterable[PublishedRunVisibility]: + if not pr.workspace or pr.workspace.is_personal: + return {cls.UNLISTED, cls.PUBLIC, PublishedRunVisibility(pr.visibility)} else: # TODO: Add cls.PUBLIC when team-handles are added - return [cls.UNLISTED, cls.INTERNAL] + return {cls.UNLISTED, cls.INTERNAL, PublishedRunVisibility(pr.visibility)} @classmethod def get_default_for_workspace(cls, workspace: typing.Optional["Workspace"]): diff --git a/daras_ai_v2/base.py b/daras_ai_v2/base.py index 02167d0f6..3a806bb13 100644 --- a/daras_ai_v2/base.py +++ b/daras_ai_v2/base.py @@ -557,12 +557,7 @@ def _render_share_modal(self, dialog: gui.AlertDialogRef): options = { str(enum.value): enum.help_text(self.current_pr.workspace) - for enum in [ - *PublishedRunVisibility.choices_for_workspace( - self.current_pr.workspace - ), - PublishedRunVisibility(self.current_pr.visibility), - ] + for enum in PublishedRunVisibility.choices_for_pr(self.current_pr) } published_run_visibility = PublishedRunVisibility( int(