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

Create and use constants for landing zone status types #1729

Merged

Conversation

gromdimon
Copy link
Collaborator

@gromdimon gromdimon commented Jul 13, 2023

Issue #1398

TODO:

  • Implement
  • Test

@gromdimon gromdimon linked an issue Jul 13, 2023 that may be closed by this pull request
@gromdimon gromdimon marked this pull request as ready for review July 13, 2023 15:59
Copy link
Contributor

@mikkonie mikkonie left a comment

Choose a reason for hiding this comment

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

Looking good! I can see two issues:

Issue 1

Importing large amounts of these constants in modules can bloat up the import sections quite a bit. I suggest you move these and the other landingzones constants into landingzones/constants.py. Then, if you need a big bunch of these constants imported in a single module, you can instead do:

import landingzones.constants as lc
do_something_with(lc.ZONE_STATUS_OK)  # Etc etc.

Issue 2

Grep shows me there are still places where we refer to these status types by string instead of the constant. Mostly in tests but also elsewhere. Example:

(sodar14) mikkopen@cubi-7300-mn:~/code/sodar$ grep -niIr --include "*.py" "'MOVED'"
samplesheets/views.py:1358:                    status__in=['MOVED', 'DELETED']
landingzones/management/commands/inactivezones.py:23:    ).exclude(status__in=('DELETED', 'MOVED'))
landingzones/plugins.py:128:        if obj.__class__ == LandingZone and obj.status != 'MOVED':
landingzones/plugins.py:169:        active_count = zones.exclude(status__in=['MOVED', 'DELETED']).count()
landingzones/models.py:24:ZONE_STATUS_MOVED = 'MOVED'
landingzones/models.py:75:STATUS_FINISHED = ['MOVED', 'NOT CREATED', 'DELETED']
irodsadmin/management/commands/irodsorphans.py:87:            ~(Q(status='MOVED') & Q(status='DELETED'))
taskflowbackend/tests/test_flows.py:632:        self.assertEqual(self.zone.status, 'MOVED')
taskflowbackend/tests/test_flows.py:691:        self.assertEqual(self.zone.status, 'MOVED')
taskflowbackend/tests/test_flows.py:763:        self.assertEqual(self.zone.status, 'MOVED')
taskflowbackend/tests/test_flows.py:967:        self.assertEqual(new_zone.status, 'MOVED')
taskflowbackend/flows/landing_zone_move.py:329:                    'status': 'MOVED',

We should consistently use the constants everywhere.

@gromdimon gromdimon force-pushed the 1398-create-and-use-constants-for-landing-zone-status-types branch from d670085 to ea0a627 Compare August 10, 2023 10:34
Copy link
Contributor

@mikkonie mikkonie left a comment

Choose a reason for hiding this comment

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

No notes, good work! Will be merged :)

@mikkonie mikkonie merged commit 9e5f2d9 into dev Aug 14, 2023
5 checks passed
@mikkonie mikkonie deleted the 1398-create-and-use-constants-for-landing-zone-status-types branch August 14, 2023 13:42
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.

Create and use constants for landing zone status types
2 participants