django-to-galaxy 0.6.9.6__tar.gz → 0.6.9.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of django-to-galaxy might be problematic. Click here for more details.

Files changed (63) hide show
  1. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/PKG-INFO +3 -2
  2. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/admin/workflow.py +4 -4
  3. django_to_galaxy-0.6.9.8/django_to_galaxy/migrations/0011_rename__step_jobs_count_workflow__step_count_and_more.py +23 -0
  4. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/models/invocation.py +41 -12
  5. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/models/workflow.py +7 -30
  6. django_to_galaxy-0.6.9.8/django_to_galaxy/settings.py +8 -0
  7. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/version.py +1 -1
  8. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/pyproject.toml +3 -2
  9. django_to_galaxy-0.6.9.6/django_to_galaxy/settings.py +0 -8
  10. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/LICENSE +0 -0
  11. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/__init__.py +0 -0
  12. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/admin/__init__.py +0 -0
  13. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/admin/galaxy_element.py +0 -0
  14. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/admin/galaxy_instance.py +0 -0
  15. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/admin/galaxy_output_file.py +0 -0
  16. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/admin/galaxy_user.py +0 -0
  17. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/admin/history.py +0 -0
  18. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/admin/invocation.py +0 -0
  19. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/admin/tag.py +0 -0
  20. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/__init__.py +0 -0
  21. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/serializers/asymetricslugrelatedfield.py +0 -0
  22. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/serializers/galaxy_instance.py +0 -0
  23. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/serializers/galaxy_output_file.py +0 -0
  24. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/serializers/galaxy_user.py +0 -0
  25. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/serializers/history.py +0 -0
  26. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/serializers/invocation.py +0 -0
  27. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/serializers/invoke_workflow.py +0 -0
  28. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/serializers/upload_to_history.py +0 -0
  29. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/serializers/workflow.py +0 -0
  30. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/urls.py +0 -0
  31. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/views/create_history.py +0 -0
  32. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/views/galaxy_instance.py +0 -0
  33. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/views/galaxy_output_file.py +0 -0
  34. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/views/galaxy_user.py +0 -0
  35. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/views/history.py +0 -0
  36. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/views/invocation.py +0 -0
  37. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/views/invoke_workflow.py +0 -0
  38. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/views/upload_to_history.py +0 -0
  39. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/api/views/workflow.py +0 -0
  40. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/apps.py +0 -0
  41. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/migrations/0001_new_initial.py +0 -0
  42. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/migrations/0002_rename_state_history_galaxy_state_and_more.py +0 -0
  43. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/migrations/0003_invocation_create_time.py +0 -0
  44. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/migrations/0004_alter_galaxyuser_email_galaxyoutputfile.py +0 -0
  45. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/migrations/0005_alter_galaxyoutputfile_invocation_and_more.py +0 -0
  46. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/migrations/0006_tag_history_tags_workflow_tags.py +0 -0
  47. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/migrations/0007_format_alter_history_tags_alter_workflow_tags_and_more.py +0 -0
  48. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/migrations/0008_workflowinput_label.py +0 -0
  49. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/migrations/0009_galaxyoutputfile_unique_galaxy_id_per_invocation.py +0 -0
  50. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/migrations/0010_workflow__is_meta_workflow__step_jobs_count.py +0 -0
  51. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/migrations/__init__.py +0 -0
  52. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/models/__init__.py +0 -0
  53. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/models/accepted_input.py +0 -0
  54. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/models/galaxy_element.py +0 -0
  55. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/models/galaxy_instance.py +0 -0
  56. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/models/galaxy_output_file.py +0 -0
  57. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/models/galaxy_user.py +0 -0
  58. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/models/history.py +0 -0
  59. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/schemas/__init__.py +0 -0
  60. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/schemas/dataset.py +0 -0
  61. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/templates/admin/import_workflows.html +0 -0
  62. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/urls.py +0 -0
  63. {django_to_galaxy-0.6.9.6 → django_to_galaxy-0.6.9.8}/django_to_galaxy/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: django-to-galaxy
3
- Version: 0.6.9.6
3
+ Version: 0.6.9.8
4
4
  Summary: Django extension that eases communication with Galaxy instance to execute workflows.
5
5
  Author: Kenzo-Hugo Hillion
6
6
  Author-email: hillion.kenzo@posteo.net
@@ -11,5 +11,6 @@ Requires-Dist: Django (>=5.1.1,<6.0.0)
11
11
  Requires-Dist: Markdown (>=3.3.6,<4.0.0)
12
12
  Requires-Dist: bioblend (>=0.16.0,<0.17.0)
13
13
  Requires-Dist: djangorestframework (>=3.13.1,<4.0.0)
14
- Requires-Dist: pydantic (>=1.9.1,<2.0.0)
14
+ Requires-Dist: pydantic (>=2.11.0,<3.0.0)
15
+ Requires-Dist: pydantic-settings (>=2.9.0,<3.0.0)
15
16
  Requires-Dist: requests-cache (>=0.9.5,<0.10.0)
@@ -14,7 +14,7 @@ class WorkflowAdmin(GalaxyElementAdmin):
14
14
  "annotation",
15
15
  "galaxy_id",
16
16
  "get_is_meta",
17
- "get_step_jobs_count",
17
+ "get_step_count",
18
18
  "published",
19
19
  "galaxy_owner",
20
20
  "get_tags",
@@ -25,7 +25,7 @@ class WorkflowAdmin(GalaxyElementAdmin):
25
25
  "annotation",
26
26
  "galaxy_id",
27
27
  "get_is_meta",
28
- "get_step_jobs_count",
28
+ "get_step_count",
29
29
  "published",
30
30
  "galaxy_owner",
31
31
  "get_tags",
@@ -34,8 +34,8 @@ class WorkflowAdmin(GalaxyElementAdmin):
34
34
  def get_is_meta(self, obj):
35
35
  return obj.get_is_meta()
36
36
 
37
- def get_step_jobs_count(self, obj):
38
- return obj.get_step_jobs_count()
37
+ def get_step_count(self, obj):
38
+ return obj.get_step_count()
39
39
 
40
40
  def get_tags(self, obj):
41
41
  return ", ".join([p.label for p in obj.tags.all()])
@@ -0,0 +1,23 @@
1
+ # Generated by Django 5.2.3 on 2025-07-18 14:07
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("django_to_galaxy", "0010_workflow__is_meta_workflow__step_jobs_count"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.RenameField(
14
+ model_name="workflow",
15
+ old_name="_step_jobs_count",
16
+ new_name="_step_count",
17
+ ),
18
+ migrations.AlterField(
19
+ model_name="workflow",
20
+ name="_is_meta",
21
+ field=models.BooleanField(blank=True, default=None, null=True),
22
+ ),
23
+ ]
@@ -57,7 +57,7 @@ class Invocation(models.Model):
57
57
  step_job_summary["states"] = {}
58
58
  step_job_summary["id"] = step_job.job_id
59
59
  step_job_summary["states"][
60
- self.workflow.galaxy_owner.obj_gi.jobs.get(step_job.job_id).state
60
+ self.galaxy_invocation.gi.jobs.get(step_job.job_id).state
61
61
  ] = 1
62
62
  step_jobs_summary.append(step_job_summary)
63
63
 
@@ -88,37 +88,66 @@ class Invocation(models.Model):
88
88
 
89
89
  @property
90
90
  def percentage_done(self) -> float:
91
- """Retrieve percentage of jobs done for the invocation."""
91
+ """Retrieve percentage of steps done for the invocation."""
92
92
  if self.status == DONE:
93
93
  return 100.0
94
94
  self.step_jobs_summary = self.step_jobs_summary()
95
95
 
96
- for step in self.galaxy_invocation.steps:
96
+ inv_steps = self.galaxy_invocation.steps
97
+ for step in inv_steps:
97
98
  if "subworkflow_invocation_id" in step.wrapped:
98
99
  if step.wrapped["subworkflow_invocation_id"]:
99
100
  self.complet_jobs_summary(step)
100
101
 
101
- count_states = defaultdict(int)
102
+ count_job_states = defaultdict(int)
102
103
  for step in self.step_jobs_summary:
103
104
  for key in step["states"].keys():
104
- count_states[key] += 1
105
+ count_job_states[key] += 1
106
+ count_scheduled_steps = sum(step.state == "scheduled" for step in inv_steps)
107
+ wf_step_count = self.workflow._step_count
105
108
  try:
106
- percentage_done = (
107
- count_states.get("ok", 0) / self.workflow.get_step_jobs_count()
108
- )
109
+ percentage_done = count_scheduled_steps / wf_step_count
109
110
  except ZeroDivisionError:
110
111
  percentage_done = 0
111
112
  if percentage_done == 1:
112
- self.status = DONE
113
- self.save()
114
- if "error" in count_states.keys():
113
+ last_job = inv_steps[wf_step_count - 1]
114
+ if self.check_if_last_job_is_ok(last_job):
115
+ self.status = DONE
116
+ self.save()
117
+ else:
118
+ try:
119
+ percentage_done = (count_scheduled_steps - 1) / wf_step_count
120
+ except ZeroDivisionError:
121
+ percentage_done = 0
122
+ if "error" in count_job_states.keys():
115
123
  self.status = ERROR
116
124
  self.save()
117
- elif "paused" in count_states.keys():
125
+ elif "paused" in count_job_states.keys():
118
126
  self.status = PAUSED
119
127
  self.save()
120
128
  return percentage_done * 100
121
129
 
130
+ def check_if_last_job_is_ok(self, last_job):
131
+ """Checks if the very last job is done"""
132
+ if last_job.job_id:
133
+ return self.galaxy_invocation.gi.jobs.get(last_job.job_id).state == "ok"
134
+ if (
135
+ "subworkflow_invocation_id" in last_job.wrapped
136
+ and last_job.wrapped["subworkflow_invocation_id"]
137
+ and len(
138
+ self.galaxy_invocation.gi.invocations.get(
139
+ last_job.wrapped["subworkflow_invocation_id"]
140
+ ).steps
141
+ )
142
+ > 0
143
+ ):
144
+ return self.check_if_last_job_is_ok(
145
+ self.galaxy_invocation.gi.invocations.get(
146
+ last_job.wrapped["subworkflow_invocation_id"]
147
+ ).steps[-1]
148
+ )
149
+ return False
150
+
122
151
  @property
123
152
  def job_id_to_tools(self) -> Dict[str, dict]:
124
153
  """Dict of job_id to wrapped tool."""
@@ -15,8 +15,8 @@ class Workflow(GalaxyElement):
15
15
  "GalaxyUser", null=False, on_delete=models.CASCADE, related_name="workflows"
16
16
  )
17
17
  """Galaxy user that owns the workflow."""
18
- _step_jobs_count = models.PositiveIntegerField(default=0)
19
- """Number of step jobs of the workflow."""
18
+ _step_count = models.PositiveIntegerField(default=0)
19
+ """Number of steps in the workflow."""
20
20
  _is_meta = models.BooleanField(null=True, default=None, blank=True)
21
21
  """Indicates whether the workflow is a meta (i.e., has sub-workflows) or not."""
22
22
 
@@ -43,35 +43,12 @@ class Workflow(GalaxyElement):
43
43
  self.save(update_fields=["_is_meta"])
44
44
  return self._is_meta
45
45
 
46
- def get_step_jobs_count(self):
46
+ def get_step_count(self):
47
47
  """Sets / returns _step_jobs_count value."""
48
- if self._step_jobs_count == 0:
49
- galaxy_wf = self.galaxy_workflow
50
- step_jobs_count = 0
51
- if self.get_is_meta():
52
- # Total step jobs count for a meta wf
53
- galaxy_client = self.galaxy_owner.obj_gi.gi
54
- for key, step_dict in galaxy_wf.steps.items():
55
- w = step_dict.wrapped
56
- if "workflow_id" in w:
57
- sub_wf = galaxy_client.make_get_request(
58
- galaxy_client.base_url
59
- + f"/api/workflows/{w['workflow_id']}",
60
- params={"instance": "true"},
61
- ).json()
62
- for j in range(len(sub_wf["steps"])):
63
- step = sub_wf["steps"][str(j)]
64
- if "input" not in step["type"]:
65
- step_jobs_count += 1
66
- else:
67
- # Total step jobs count for a simple wf
68
- for key, step_dict in galaxy_wf.steps.items():
69
- w = step_dict.wrapped
70
- if "input" not in w["type"]:
71
- step_jobs_count += 1
72
- self._step_jobs_count = step_jobs_count
73
- self.save(update_fields=["_step_jobs_count"])
74
- return self._step_jobs_count
48
+ if self._step_count == 0:
49
+ self._step_count = len(self.galaxy_workflow.steps)
50
+ self.save(update_fields=["_step_count"])
51
+ return self._step_count
75
52
 
76
53
  def invoke(self, datamap: dict, history: History) -> wrappers.Invocation:
77
54
  """
@@ -0,0 +1,8 @@
1
+ from pydantic_settings import BaseSettings
2
+
3
+
4
+ class Settings(BaseSettings):
5
+ GALAXY_TIME_FORMAT: str = "%Y-%m-%dT%H:%M:%S.%f"
6
+
7
+
8
+ settings = Settings()
@@ -1,3 +1,3 @@
1
1
  """Handle library versioning."""
2
- version_info = (0, 6, 9, 6)
2
+ version_info = (0, 6, 9, 8)
3
3
  __version__ = ".".join(str(c) for c in version_info)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "django-to-galaxy"
3
- version = "0.6.9.6"
3
+ version = "0.6.9.8"
4
4
  description = "Django extension that eases communication with Galaxy instance to execute workflows."
5
5
  authors = ["Kenzo-Hugo Hillion <hillion.kenzo@posteo.net>"]
6
6
 
@@ -10,7 +10,8 @@ Django = "^5.1.1"
10
10
  bioblend = "^0.16.0"
11
11
  djangorestframework = "^3.13.1"
12
12
  Markdown = "^3.3.6"
13
- pydantic = "^1.9.1"
13
+ pydantic = "^2.11.0"
14
+ pydantic-settings = "^2.9.0"
14
15
  requests-cache = "^0.9.5"
15
16
 
16
17
  [tool.poetry.dev-dependencies]
@@ -1,8 +0,0 @@
1
- from pydantic import BaseSettings
2
-
3
-
4
- class Settings(BaseSettings):
5
- GALAXY_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
6
-
7
-
8
- settings = Settings()