Skip to content
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

Remove setup as default from python manage.py packages to prevent fatal mistakes #10577

Conversation

SDScandrettKint
Copy link
Member

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Description of Change

Replaces the default python manage.py packages command with a helpful prompt to use --help to learn more about the command rather than resetting the database.

Could replace setup with another of the commands, but a non-harming message seemed better even though it isn't in the choices list. If the default value could call --help that would be better, but I'm not sure if that is possible

Issues Solved

#10103

Checklist

  • Unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Ticket Background

  • Sponsored by: Knowledge Integration
  • Found by: @SDScandrettKint
  • Tested by: @
  • Designed by: @

Further comments

Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

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

Nice idea to just print help. I was able to get the help printed like this:

diff --git a/arches/management/commands/packages.py b/arches/management/commands/packages.py
index 3797afa17..43904d006 100644
--- a/arches/management/commands/packages.py
+++ b/arches/management/commands/packages.py
@@ -73,7 +73,6 @@ class Command(BaseCommand):
             "--operation",
             action="store",
             dest="operation",
-            default="setup",
             choices=[
                 "setup",
                 "install",
@@ -263,6 +262,10 @@ class Command(BaseCommand):
         parser.add_argument("--languages", action="store", dest="languages", help="languages desired as a comma separated list")
 
     def handle(self, *args, **options):
+        if options["operation"] is None:
+            self.print_help("manage.py", "packages")
+            return
+
         print("operation: " + options["operation"])
         package_name = settings.PACKAGE_NAME
         celery_worker_running = task_management.check_if_celery_available()

@SDScandrettKint
Copy link
Member Author

Nice idea to just print help. I was able to get the help printed like this:

diff --git a/arches/management/commands/packages.py b/arches/management/commands/packages.py
index 3797afa17..43904d006 100644
--- a/arches/management/commands/packages.py
+++ b/arches/management/commands/packages.py
@@ -73,7 +73,6 @@ class Command(BaseCommand):
             "--operation",
             action="store",
             dest="operation",
-            default="setup",
             choices=[
                 "setup",
                 "install",
@@ -263,6 +262,10 @@ class Command(BaseCommand):
         parser.add_argument("--languages", action="store", dest="languages", help="languages desired as a comma separated list")
 
     def handle(self, *args, **options):
+        if options["operation"] is None:
+            self.print_help("manage.py", "packages")
+            return
+
         print("operation: " + options["operation"])
         package_name = settings.PACKAGE_NAME
         celery_worker_running = task_management.check_if_celery_available()

That's a great idea and find! I've added these changes in the latest commit.

Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@jacobtylerwalls jacobtylerwalls merged commit 95597b4 into archesproject:dev/7.6.x Feb 2, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants