gpp-client 26.11.1.dev1__tar.gz → 26.11.2.dev1__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.
Files changed (115) hide show
  1. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/PKG-INFO +1 -1
  2. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/domains/scheduler.py +96 -94
  3. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/__init__.py +12 -0
  4. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/custom_fields.py +160 -3
  5. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/custom_mutations.py +36 -0
  6. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/custom_typing_fields.py +24 -0
  7. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/enums.py +13 -0
  8. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/input_types.py +79 -1
  9. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/.gitignore +0 -0
  10. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/LICENSE +0 -0
  11. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/README.md +0 -0
  12. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/graphql/README.md +0 -0
  13. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/pyproject.toml +0 -0
  14. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/__init__.py +0 -0
  15. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/__init__.py +0 -0
  16. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/cli.py +0 -0
  17. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/commands/__init__.py +0 -0
  18. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/commands/attachment.py +0 -0
  19. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/commands/goats.py +0 -0
  20. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/commands/observation.py +0 -0
  21. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/commands/program.py +0 -0
  22. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/commands/scheduler.py +0 -0
  23. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/commands/site_status.py +0 -0
  24. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/commands/target.py +0 -0
  25. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/commands/workflow_state.py +0 -0
  26. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/console.py +0 -0
  27. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/output.py +0 -0
  28. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/cli/utils.py +0 -0
  29. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/client.py +0 -0
  30. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/constants.py +0 -0
  31. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/domains/__init__.py +0 -0
  32. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/domains/atom.py +0 -0
  33. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/domains/attachment.py +0 -0
  34. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/domains/base.py +0 -0
  35. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/domains/goats.py +0 -0
  36. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/domains/observation.py +0 -0
  37. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/domains/program.py +0 -0
  38. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/domains/site_status.py +0 -0
  39. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/domains/target.py +0 -0
  40. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/domains/workflow_state.py +0 -0
  41. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/environment.py +0 -0
  42. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/exceptions.py +0 -0
  43. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/async_base_client.py +0 -0
  44. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/base_model.py +0 -0
  45. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/base_operation.py +0 -0
  46. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/client.py +0 -0
  47. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/clone_observation.py +0 -0
  48. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/clone_target.py +0 -0
  49. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/create_call_for_proposals.py +0 -0
  50. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/create_observation.py +0 -0
  51. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/create_program.py +0 -0
  52. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/create_target_by_program_id.py +0 -0
  53. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/create_target_by_program_reference.py +0 -0
  54. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/create_target_by_proposal_reference.py +0 -0
  55. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/custom_queries.py +0 -0
  56. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/delete_call_for_proposals_by_id.py +0 -0
  57. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/delete_observation_by_id.py +0 -0
  58. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/delete_observation_by_reference.py +0 -0
  59. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/delete_program_by_id.py +0 -0
  60. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/delete_target_by_id.py +0 -0
  61. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/exceptions.py +0 -0
  62. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/fragments.py +0 -0
  63. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_call_for_proposals.py +0 -0
  64. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_calls_for_proposals.py +0 -0
  65. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_goats_config_options.py +0 -0
  66. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_goats_configuration_requests.py +0 -0
  67. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_goats_observations.py +0 -0
  68. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_goats_programs.py +0 -0
  69. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_observation.py +0 -0
  70. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_observation_attachments_by_id.py +0 -0
  71. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_observation_attachments_by_reference.py +0 -0
  72. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_observation_workflow_state_by_id.py +0 -0
  73. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_observation_workflow_state_by_reference.py +0 -0
  74. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_observations.py +0 -0
  75. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_program_attachments_by_id.py +0 -0
  76. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_program_attachments_by_proposal_reference.py +0 -0
  77. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_program_attachments_by_reference.py +0 -0
  78. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_program_by_id.py +0 -0
  79. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_program_by_proposal_reference.py +0 -0
  80. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_program_by_reference.py +0 -0
  81. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_programs.py +0 -0
  82. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_scheduler_all_programs_id.py +0 -0
  83. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_scheduler_programs.py +0 -0
  84. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_target_by_id.py +0 -0
  85. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/get_targets.py +0 -0
  86. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/obs_calculation_update.py +0 -0
  87. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/observation_edit.py +0 -0
  88. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/package_environment.py +0 -0
  89. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/ping.py +0 -0
  90. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/program_edit.py +0 -0
  91. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/restore_call_for_proposals_by_id.py +0 -0
  92. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/restore_observation_by_id.py +0 -0
  93. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/restore_observation_by_reference.py +0 -0
  94. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/restore_program_by_id.py +0 -0
  95. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/restore_target_by_id.py +0 -0
  96. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/scheduler_executed_events.py +0 -0
  97. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/scheduler_observations_updates.py +0 -0
  98. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/set_observation_workflow_state.py +0 -0
  99. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/target_edit.py +0 -0
  100. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/update_call_for_proposals_by_id.py +0 -0
  101. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/update_calls_for_proposals.py +0 -0
  102. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/update_observation_by_id.py +0 -0
  103. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/update_observation_by_reference.py +0 -0
  104. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/update_observations.py +0 -0
  105. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/update_program_by_id.py +0 -0
  106. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/update_programs.py +0 -0
  107. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/update_target_by_id.py +0 -0
  108. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/generated/update_targets.py +0 -0
  109. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/logging_utils.py +0 -0
  110. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/rest/__init__.py +0 -0
  111. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/rest/client.py +0 -0
  112. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/rest/models.py +0 -0
  113. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/rest/utils.py +0 -0
  114. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/settings.py +0 -0
  115. {gpp_client-26.11.1.dev1 → gpp_client-26.11.2.dev1}/src/gpp_client/urls.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: gpp-client
3
- Version: 26.11.1.dev1
3
+ Version: 26.11.2.dev1
4
4
  Summary: Gemini Program Platform client.
5
5
  Project-URL: Homepage, https://github.com/gemini-hlsw/gpp-client
6
6
  Project-URL: Source, https://github.com/gemini-hlsw/gpp-client
@@ -5,9 +5,10 @@ Module for retrieving scheduler information.
5
5
  __all__ = ["SchedulerDomain"]
6
6
 
7
7
  from datetime import datetime
8
- from typing import Any, AsyncIterator, Awaitable, Callable
8
+ from typing import Any, AsyncIterator, Iterator
9
9
 
10
10
  from gpp_client.domains.base import BaseDomain
11
+ from gpp_client.exceptions import GPPClientError
11
12
  from gpp_client.rest.models import VisibilityChanges, parse_visibility_changes
12
13
  from gpp_client.generated import (
13
14
  SchedulerObservationsUpdates,
@@ -25,83 +26,81 @@ from gpp_client.generated.input_types import (
25
26
  ObservationWorkflowState,
26
27
  WhereCalculatedObservationWorkflow,
27
28
  WhereObservation,
29
+ WhereOrderObservationId,
28
30
  WhereOrderObservationWorkflowState,
29
- WhereOrderProgramId,
30
- WhereProgram,
31
31
  )
32
32
 
33
- # Each program carries its full group tree, so large pages are heavy for the ODB.
34
- PROGRAMS_PAGE_SIZE = 1000
35
- OBSERVATIONS_PAGE_SIZE = 1000
33
+ # The ODB returns at most this many matches per select. Asking for at most this
34
+ # many IDs at a time means a batch can never be cut short.
35
+ ID_BATCH_SIZE = 1000
36
36
 
37
37
 
38
- class SchedulerDomain(BaseDomain):
39
- """
40
- Domain for retrieving scheduler information.
38
+ def _id_batches(ids: list[str]) -> Iterator[list[str]]:
41
39
  """
40
+ Split IDs into batches no larger than the ODB select cap, dropping repeats.
42
41
 
43
- @staticmethod
44
- async def _fetch_all_pages(
45
- fetch_page: Callable[[str | None, int], Awaitable[Any]],
46
- page_size: int,
47
- ) -> list[Any]:
48
- """
49
- Walk an ``OFFSET``/``LIMIT`` selection one page at a time and return
50
- every match.
42
+ Parameters
43
+ ----------
44
+ ids : list[str]
45
+ IDs to split, in the order to query them.
51
46
 
52
- Parameters
53
- ----------
54
- fetch_page : Callable[[str | None, int], Awaitable[Any]]
55
- Coroutine taking ``offset`` and ``limit`` and returning a select
56
- result with ``matches`` and ``has_more``.
57
- page_size : int
58
- Number of matches requested per page. Must be at least 2.
47
+ Yields
48
+ ------
49
+ list[str]
50
+ The next batch of at most ``ID_BATCH_SIZE`` unique IDs.
51
+ """
52
+ unique = list(dict.fromkeys(ids))
53
+ for start in range(0, len(unique), ID_BATCH_SIZE):
54
+ yield unique[start : start + ID_BATCH_SIZE]
59
55
 
60
- Returns
61
- -------
62
- list[Any]
63
- Every match across all pages, without repeats.
64
56
 
65
- Raises
66
- ------
67
- ValueError
68
- If ``page_size`` is lower than 2.
69
- """
70
- # OFFSET is inclusive, so every page after the first repeats the previous
71
- # page's last match. A page of 1 would never advance.
72
- if page_size < 2:
73
- raise ValueError(f"page_size must be at least 2, got {page_size}.")
57
+ def _require_complete(result: Any, what: str) -> None:
58
+ """
59
+ Fail when the ODB says it left matches out.
60
+
61
+ Parameters
62
+ ----------
63
+ result : Any
64
+ Select result with ``matches`` and ``has_more``.
65
+ what : str
66
+ Plural name of the selected items, for the message.
67
+
68
+ Raises
69
+ ------
70
+ GPPClientError
71
+ If ``result.has_more`` is set.
72
+ """
73
+ # The scheduler must see every observation. A partial answer is worse than
74
+ # no answer, so stop instead of returning it.
75
+ if result.has_more:
76
+ raise GPPClientError(
77
+ f"ODB returned {len(result.matches)} {what} and reported more that "
78
+ "were left out; refusing to return an incomplete result."
79
+ )
74
80
 
75
- matches = []
76
- offset = None
77
- while True:
78
- result = await fetch_page(offset, page_size)
79
- page_matches = result.matches
80
- if offset is not None and page_matches and page_matches[0].id == offset:
81
- page_matches = page_matches[1:]
82
- matches.extend(page_matches)
83
-
84
- if not result.has_more or not page_matches:
85
- return matches
86
- offset = page_matches[-1].id
81
+
82
+ class SchedulerDomain(BaseDomain):
83
+ """
84
+ Domain for retrieving scheduler information.
85
+ """
87
86
 
88
87
  async def get_programs(
89
88
  self,
90
89
  *,
91
90
  programs_list: list[str] | None = None,
92
- page_size: int = PROGRAMS_PAGE_SIZE,
93
91
  ) -> GetSchedulerPrograms:
94
92
  """
95
- Get active scheduler programs, fetching every page so the result reads
96
- as a single query.
93
+ Get active scheduler programs.
94
+
95
+ Given a list, the IDs are queried in batches that the ODB can always
96
+ answer in full, so every active program in the list comes back. Without
97
+ a list, all active programs come from a single query.
97
98
 
98
99
  Parameters
99
100
  ----------
100
101
  programs_list : list[str] | None, optional
101
102
  Optional list of program IDs to restrict the result set. Inactive
102
103
  programs in the list are left out.
103
- page_size : int, optional
104
- Number of programs requested per page. Must be at least 2.
105
104
 
106
105
  Returns
107
106
  -------
@@ -110,17 +109,19 @@ class SchedulerDomain(BaseDomain):
110
109
 
111
110
  Raises
112
111
  ------
113
- ValueError
114
- If ``page_size`` is lower than 2.
112
+ GPPClientError
113
+ If the ODB reports matches it did not return.
115
114
  """
115
+ if programs_list is None:
116
+ response = await self._graphql.get_scheduler_programs(programs_list=None)
117
+ _require_complete(response.programs, "programs")
118
+ return response
116
119
 
117
- async def fetch_page(offset: str | None, limit: int) -> Any:
118
- page = await self._graphql.get_scheduler_programs(
119
- programs_list=programs_list, offset=offset, limit=limit
120
- )
121
- return page.programs
122
-
123
- matches = await self._fetch_all_pages(fetch_page, page_size)
120
+ matches = []
121
+ for batch in _id_batches(programs_list):
122
+ response = await self._graphql.get_scheduler_programs(programs_list=batch)
123
+ _require_complete(response.programs, "programs")
124
+ matches.extend(response.programs.matches)
124
125
  return GetSchedulerPrograms(
125
126
  programs=GetSchedulerProgramsPrograms(matches=matches, has_more=False)
126
127
  )
@@ -288,6 +289,11 @@ class SchedulerDomain(BaseDomain):
288
289
  -------
289
290
  list[dict[str, Any]]
290
291
  A list of dictionaries representing the programs and their elements.
292
+
293
+ Raises
294
+ ------
295
+ GPPClientError
296
+ If the ODB reports programs or observations it did not return.
291
297
  """
292
298
 
293
299
  if not programs_list:
@@ -339,39 +345,35 @@ class SchedulerDomain(BaseDomain):
339
345
  pass
340
346
  program["root"] = root
341
347
 
342
- where_observation = WhereObservation(
343
- program=WhereProgram(
344
- id=WhereOrderProgramId(in_=[p["id"] for p in programs])
345
- ),
346
- workflow=WhereCalculatedObservationWorkflow(
347
- workflow_state=WhereOrderObservationWorkflowState(
348
- in_=[
349
- ObservationWorkflowState.READY,
350
- ObservationWorkflowState.ONGOING,
351
- ]
352
- )
353
- ),
354
- observing_mode_type=WhereOptionEqObservingModeType(
355
- is_null=False,
356
- ),
357
- )
358
-
359
- # Get observation data, only once every program page is in.
360
- async def fetch_observations_page(offset: str | None, limit: int) -> Any:
361
- page = await self._graphql.get_observations(
362
- where=where_observation,
363
- offset=offset,
364
- limit=limit,
348
+ tree_obs_ids = [
349
+ g["observation"]["id"]
350
+ for program in programs
351
+ for g in program["all_group_elements"]
352
+ if g.get("observation")
353
+ ]
354
+ obs_mapping = {}
355
+ # Query on 1000 observation ids (max pagination limit)
356
+ for batch in _id_batches(tree_obs_ids):
357
+ obs_response = await self._graphql.get_observations(
358
+ where=WhereObservation(
359
+ id=WhereOrderObservationId(in_=batch),
360
+ workflow=WhereCalculatedObservationWorkflow(
361
+ workflow_state=WhereOrderObservationWorkflowState(
362
+ in_=[
363
+ ObservationWorkflowState.READY,
364
+ ObservationWorkflowState.ONGOING,
365
+ ]
366
+ )
367
+ ),
368
+ observing_mode_type=WhereOptionEqObservingModeType(
369
+ is_null=False,
370
+ ),
371
+ ),
365
372
  include_deleted=False,
366
373
  )
367
- return page.observations
368
-
369
- obs_matches = await self._fetch_all_pages(
370
- fetch_observations_page, OBSERVATIONS_PAGE_SIZE
371
- )
372
- obs_mapping = {
373
- o.id: self._move_timing_windows_to_root(o.model_dump()) for o in obs_matches
374
- }
374
+ _require_complete(obs_response.observations, "observations")
375
+ for o in obs_response.observations.matches:
376
+ obs_mapping[o.id] = self._move_timing_windows_to_root(o.model_dump())
375
377
 
376
378
  # Get sequence for filtered observations (READY/ONGOING)
377
379
  if obs_mapping:
@@ -113,6 +113,7 @@ from .enums import (
113
113
  ExecutionState,
114
114
  Existence,
115
115
  FieldLens,
116
+ Flamingos2AcquisitionType,
116
117
  Flamingos2CustomSlitWidth,
117
118
  Flamingos2Decker,
118
119
  Flamingos2Disperser,
@@ -237,6 +238,7 @@ from .enums import (
237
238
  SubaruCallForProposalsType,
238
239
  SubaruInstrument,
239
240
  TacCategory,
241
+ TacPartnerDecision,
240
242
  TargetDisposition,
241
243
  TelescopeConfigGeneratorType,
242
244
  TelluricTag,
@@ -1120,6 +1122,7 @@ from .input_types import (
1120
1122
  DeleteProgramUserInput,
1121
1123
  DeleteProposalInput,
1122
1124
  DeleteSequenceInput,
1125
+ DeleteTacFeedbackInput,
1123
1126
  DemoScienceInput,
1124
1127
  DirectorsTimeInput,
1125
1128
  EditAsterismsPatchInput,
@@ -1289,6 +1292,7 @@ from .input_types import (
1289
1292
  SetProgramReferenceInput,
1290
1293
  SetProgramResourceLimitInput,
1291
1294
  SetProposalStatusInput,
1295
+ SetTacFeedbackInput,
1292
1296
  SiderealInput,
1293
1297
  SignalToNoiseExposureTimeModeInput,
1294
1298
  SiteCoordinateLimitsInput,
@@ -1304,6 +1308,8 @@ from .input_types import (
1304
1308
  SubaruCallPropertiesInput,
1305
1309
  SubaruProposalTypeInput,
1306
1310
  SystemVerificationInput,
1311
+ TacFeedbackInput,
1312
+ TacRecommendedTimeInput,
1307
1313
  TargetEditInput,
1308
1314
  TargetEnvironmentInput,
1309
1315
  TargetPropertiesInput,
@@ -1764,6 +1770,7 @@ __all__ = [
1764
1770
  "DeleteProgramUserInput",
1765
1771
  "DeleteProposalInput",
1766
1772
  "DeleteSequenceInput",
1773
+ "DeleteTacFeedbackInput",
1767
1774
  "DeleteTargetById",
1768
1775
  "DeleteTargetByIdUpdateTargets",
1769
1776
  "DeleteTargetByIdUpdateTargetsTargets",
@@ -1791,6 +1798,7 @@ __all__ = [
1791
1798
  "ExposureTimeModeInput",
1792
1799
  "FastTurnaroundInput",
1793
1800
  "FieldLens",
1801
+ "Flamingos2AcquisitionType",
1794
1802
  "Flamingos2AtomInput",
1795
1803
  "Flamingos2CustomMaskInput",
1796
1804
  "Flamingos2CustomSlitWidth",
@@ -2893,6 +2901,7 @@ __all__ = [
2893
2901
  "SetProgramReferenceInput",
2894
2902
  "SetProgramResourceLimitInput",
2895
2903
  "SetProposalStatusInput",
2904
+ "SetTacFeedbackInput",
2896
2905
  "SiderealInput",
2897
2906
  "SiderealTargetDetails",
2898
2907
  "SiderealTargetDetailsDec",
@@ -2924,6 +2933,9 @@ __all__ = [
2924
2933
  "SubaruProposalTypeInput",
2925
2934
  "SystemVerificationInput",
2926
2935
  "TacCategory",
2936
+ "TacFeedbackInput",
2937
+ "TacPartnerDecision",
2938
+ "TacRecommendedTimeInput",
2927
2939
  "TargetCore",
2928
2940
  "TargetDetails",
2929
2941
  "TargetDetailsNonsidereal",
@@ -114,6 +114,7 @@ from .custom_typing_fields import (
114
114
  DeleteProgramUserResultGraphQLField,
115
115
  DeleteProposalResultGraphQLField,
116
116
  DeleteSequenceResultGraphQLField,
117
+ DeleteTacFeedbackResultGraphQLField,
117
118
  DemoScienceGraphQLField,
118
119
  DetectorEstimateGraphQLField,
119
120
  DirectorsTimeGraphQLField,
@@ -386,6 +387,9 @@ from .custom_typing_fields import (
386
387
  SubaruProposalTypeGraphQLField,
387
388
  SystemProgramReferenceGraphQLField,
388
389
  SystemVerificationGraphQLField,
390
+ TacFeedbackGraphQLField,
391
+ TacFeedbackResultGraphQLField,
392
+ TacRecommendedTimeGraphQLField,
389
393
  TargetEnvironmentGraphQLField,
390
394
  TargetGraphQLField,
391
395
  TargetGroupGraphQLField,
@@ -1765,14 +1769,26 @@ class CalibrationSetFields(GraphQLField):
1765
1769
  """IGRINS-2 setup, when the instrument is IGRINS-2."""
1766
1770
  return Igrins2DynamicFields("igrins2")
1767
1771
 
1772
+ @classmethod
1773
+ def gnirs(cls) -> "GnirsDynamicFields":
1774
+ """GNIRS setup, when the instrument is GNIRS."""
1775
+ return GnirsDynamicFields("gnirs")
1776
+
1777
+ @classmethod
1778
+ def ghost(cls) -> "GhostDynamicFields":
1779
+ """GHOST setup, when the instrument is GHOST."""
1780
+ return GhostDynamicFields("ghost")
1781
+
1768
1782
  def fields(
1769
1783
  self,
1770
1784
  *subfields: Union[
1771
1785
  CalibrationSetGraphQLField,
1772
1786
  "CalibrationSetGcalFields",
1773
1787
  "Flamingos2DynamicFields",
1788
+ "GhostDynamicFields",
1774
1789
  "GmosNorthDynamicFields",
1775
1790
  "GmosSouthDynamicFields",
1791
+ "GnirsDynamicFields",
1776
1792
  "Igrins2DynamicFields",
1777
1793
  ],
1778
1794
  ) -> "CalibrationSetFields":
@@ -3886,6 +3902,26 @@ class DeleteSequenceResultFields(GraphQLField):
3886
3902
  return self
3887
3903
 
3888
3904
 
3905
+ class DeleteTacFeedbackResultFields(GraphQLField):
3906
+ """The result of deleting TAC feedback."""
3907
+
3908
+ result: "DeleteTacFeedbackResultGraphQLField" = DeleteTacFeedbackResultGraphQLField(
3909
+ "result"
3910
+ )
3911
+ "`true` if TAC feedback was deleted, `false` otherwise."
3912
+
3913
+ def fields(
3914
+ self, *subfields: DeleteTacFeedbackResultGraphQLField
3915
+ ) -> "DeleteTacFeedbackResultFields":
3916
+ """Subfields should come from the DeleteTacFeedbackResultFields class"""
3917
+ self._subfields.extend(subfields)
3918
+ return self
3919
+
3920
+ def alias(self, alias: str) -> "DeleteTacFeedbackResultFields":
3921
+ self._alias = alias
3922
+ return self
3923
+
3924
+
3889
3925
  class DemoScienceFields(GraphQLField):
3890
3926
  """Proposal properties for Demo Science CallForProposals."""
3891
3927
 
@@ -5132,10 +5168,23 @@ class Flamingos2LongSlitAcquisitionFields(GraphQLField):
5132
5168
  """The exposure time mode used for ITC lookup for the acquisition sequence."""
5133
5169
  return ExposureTimeModeFields("exposureTimeMode")
5134
5170
 
5171
+ explicit_acquisition_type: "Flamingos2LongSlitAcquisitionGraphQLField" = (
5172
+ Flamingos2LongSlitAcquisitionGraphQLField("explicitAcquisitionType")
5173
+ )
5174
+ "An explicitly specified acquisition type (if any). When null, the ITC\nclassifies the target: BRIGHT when it reaches a signal-to-noise of 10 in a\ntotal exposure time of at most 2 seconds, FAINT otherwise."
5175
+
5176
+ @classmethod
5177
+ def sky_offset(cls) -> "OffsetFields":
5178
+ """Where the sky frames of a FAINT acquisition are taken. Present exactly when
5179
+ `explicitAcquisitionType` is FAINT."""
5180
+ return OffsetFields("skyOffset")
5181
+
5135
5182
  def fields(
5136
5183
  self,
5137
5184
  *subfields: Union[
5138
- Flamingos2LongSlitAcquisitionGraphQLField, "ExposureTimeModeFields"
5185
+ Flamingos2LongSlitAcquisitionGraphQLField,
5186
+ "ExposureTimeModeFields",
5187
+ "OffsetFields",
5139
5188
  ],
5140
5189
  ) -> "Flamingos2LongSlitAcquisitionFields":
5141
5190
  """Subfields should come from the Flamingos2LongSlitAcquisitionFields class"""
@@ -5279,10 +5328,23 @@ class Flamingos2MosAcquisitionFields(GraphQLField):
5279
5328
  """The Time & Count exposure time mode used for the acquisition sequence."""
5280
5329
  return ExposureTimeModeFields("exposureTimeMode")
5281
5330
 
5331
+ explicit_acquisition_type: "Flamingos2MosAcquisitionGraphQLField" = (
5332
+ Flamingos2MosAcquisitionGraphQLField("explicitAcquisitionType")
5333
+ )
5334
+ "An explicitly specified acquisition type (if any). When null, the acquisition\nis FAINT: the brightness of the mask's acquisition stars is unknown."
5335
+
5336
+ @classmethod
5337
+ def sky_offset(cls) -> "OffsetFields":
5338
+ """Where the sky frames of a FAINT acquisition are taken. Present exactly when
5339
+ `explicitAcquisitionType` is FAINT."""
5340
+ return OffsetFields("skyOffset")
5341
+
5282
5342
  def fields(
5283
5343
  self,
5284
5344
  *subfields: Union[
5285
- Flamingos2MosAcquisitionGraphQLField, "ExposureTimeModeFields"
5345
+ Flamingos2MosAcquisitionGraphQLField,
5346
+ "ExposureTimeModeFields",
5347
+ "OffsetFields",
5286
5348
  ],
5287
5349
  ) -> "Flamingos2MosAcquisitionFields":
5288
5350
  """Subfields should come from the Flamingos2MosAcquisitionFields class"""
@@ -11652,7 +11714,18 @@ class PartnerSplitFields(GraphQLField):
11652
11714
  percent: "PartnerSplitGraphQLField" = PartnerSplitGraphQLField("percent")
11653
11715
  "Percentage of requested time that should be associated with the partner."
11654
11716
 
11655
- def fields(self, *subfields: PartnerSplitGraphQLField) -> "PartnerSplitFields":
11717
+ @classmethod
11718
+ def lead(cls) -> "ProgramUserFields":
11719
+ """The partner lead: the investigator the partner contacts during ITAC. Each
11720
+ partner with requested time needs a lead before the proposal can be submitted.
11721
+ The lead is an investigator affiliated with the partner, and the PI is always
11722
+ the lead of the PI's own partner (a non-partner PI leads US). Null until a
11723
+ lead is assigned, and always null for a partner without requested time."""
11724
+ return ProgramUserFields("lead")
11725
+
11726
+ def fields(
11727
+ self, *subfields: Union[PartnerSplitGraphQLField, "ProgramUserFields"]
11728
+ ) -> "PartnerSplitFields":
11656
11729
  """Subfields should come from the PartnerSplitFields class"""
11657
11730
  self._subfields.extend(subfields)
11658
11731
  return self
@@ -11908,6 +11981,11 @@ class ProgramFields(GraphQLField):
11908
11981
  """All partner time allocations."""
11909
11982
  return AllocationFields("allocations")
11910
11983
 
11984
+ @classmethod
11985
+ def tac_feedback(cls) -> "TacFeedbackFields":
11986
+ """TAC feedback from each partner that has provided it, ordered by partner."""
11987
+ return TacFeedbackFields("tacFeedback")
11988
+
11911
11989
  calibration_role: "ProgramGraphQLField" = ProgramGraphQLField("calibrationRole")
11912
11990
  "Calibration role of the program"
11913
11991
 
@@ -11963,6 +12041,7 @@ class ProgramFields(GraphQLField):
11963
12041
  "ProgramUserFields",
11964
12042
  "ProposalFields",
11965
12043
  "ProposalSummaryGenerationFields",
12044
+ "TacFeedbackFields",
11966
12045
  "UserInvitationFields",
11967
12046
  ],
11968
12047
  ) -> "ProgramFields":
@@ -12130,6 +12209,10 @@ class ProgramUserFields(GraphQLField):
12130
12209
  "classicalVisitor"
12131
12210
  )
12132
12211
  "Whether this investigator will visit to carry out the observations.\nThis property is only meaningful for classical proposals."
12212
+ is_partner_lead: "ProgramUserGraphQLField" = ProgramUserGraphQLField(
12213
+ "isPartnerLead"
12214
+ )
12215
+ "Whether this investigator is the partner lead for their partner (see\n`PartnerSplit.lead`)."
12133
12216
  display_name: "ProgramUserGraphQLField" = ProgramUserGraphQLField("displayName")
12134
12217
  "Name created preferentially from the fields of the preferred profile, falling back\nto the Orcid profile if the preferred fields are not set."
12135
12218
  email: "ProgramUserGraphQLField" = ProgramUserGraphQLField("email")
@@ -14539,6 +14622,80 @@ class SystemVerificationFields(GraphQLField):
14539
14622
  return self
14540
14623
 
14541
14624
 
14625
+ class TacFeedbackFields(GraphQLField):
14626
+ """A partner's TAC (Time Allocation Committee) feedback for a program."""
14627
+
14628
+ partner: "TacFeedbackGraphQLField" = TacFeedbackGraphQLField("partner")
14629
+ "The partner whose TAC provided the feedback."
14630
+ decision: "TacFeedbackGraphQLField" = TacFeedbackGraphQLField("decision")
14631
+ "The partner TAC's decision."
14632
+ ranking: "TacFeedbackGraphQLField" = TacFeedbackGraphQLField("ranking")
14633
+ "The partner TAC's ranking of the proposal."
14634
+
14635
+ @classmethod
14636
+ def recommended_times(cls) -> "TacRecommendedTimeFields":
14637
+ """The time recommended by the partner TAC, at most one entry per science band,
14638
+ sorted by band. Empty if the partner TAC recommends no time."""
14639
+ return TacRecommendedTimeFields("recommendedTimes")
14640
+
14641
+ comments: "TacFeedbackGraphQLField" = TacFeedbackGraphQLField("comments")
14642
+ "The partner TAC's comments, if any."
14643
+
14644
+ def fields(
14645
+ self, *subfields: Union[TacFeedbackGraphQLField, "TacRecommendedTimeFields"]
14646
+ ) -> "TacFeedbackFields":
14647
+ """Subfields should come from the TacFeedbackFields class"""
14648
+ self._subfields.extend(subfields)
14649
+ return self
14650
+
14651
+ def alias(self, alias: str) -> "TacFeedbackFields":
14652
+ self._alias = alias
14653
+ return self
14654
+
14655
+
14656
+ class TacFeedbackResultFields(GraphQLField):
14657
+ """The result of setting TAC feedback."""
14658
+
14659
+ @classmethod
14660
+ def tac_feedback(cls) -> "TacFeedbackFields":
14661
+ """The TAC feedback, as updated."""
14662
+ return TacFeedbackFields("tacFeedback")
14663
+
14664
+ def fields(
14665
+ self, *subfields: Union[TacFeedbackResultGraphQLField, "TacFeedbackFields"]
14666
+ ) -> "TacFeedbackResultFields":
14667
+ """Subfields should come from the TacFeedbackResultFields class"""
14668
+ self._subfields.extend(subfields)
14669
+ return self
14670
+
14671
+ def alias(self, alias: str) -> "TacFeedbackResultFields":
14672
+ self._alias = alias
14673
+ return self
14674
+
14675
+
14676
+ class TacRecommendedTimeFields(GraphQLField):
14677
+ """The time recommended by a partner TAC for a science band."""
14678
+
14679
+ band: "TacRecommendedTimeGraphQLField" = TacRecommendedTimeGraphQLField("band")
14680
+ "The science band for which the time is recommended."
14681
+
14682
+ @classmethod
14683
+ def time(cls) -> "TimeSpanFields":
14684
+ """The time recommended for this band."""
14685
+ return TimeSpanFields("time")
14686
+
14687
+ def fields(
14688
+ self, *subfields: Union[TacRecommendedTimeGraphQLField, "TimeSpanFields"]
14689
+ ) -> "TacRecommendedTimeFields":
14690
+ """Subfields should come from the TacRecommendedTimeFields class"""
14691
+ self._subfields.extend(subfields)
14692
+ return self
14693
+
14694
+ def alias(self, alias: str) -> "TacRecommendedTimeFields":
14695
+ self._alias = alias
14696
+ return self
14697
+
14698
+
14542
14699
  class TargetFields(GraphQLField):
14543
14700
  """Target description"""
14544
14701
 
@@ -27,6 +27,7 @@ from .custom_fields import (
27
27
  DeleteProgramUserResultFields,
28
28
  DeleteProposalResultFields,
29
29
  DeleteSequenceResultFields,
30
+ DeleteTacFeedbackResultFields,
30
31
  EmailFields,
31
32
  InsertSmartGcalResultFields,
32
33
  LinkUserResultFields,
@@ -53,6 +54,7 @@ from .custom_fields import (
53
54
  SetProgramReferenceResultFields,
54
55
  SetProgramResourceLimitResultFields,
55
56
  SetProposalStatusResultFields,
57
+ TacFeedbackResultFields,
56
58
  UnlinkUserResultFields,
57
59
  UpdateAsterismsResultFields,
58
60
  UpdateAttachmentsResultFields,
@@ -94,6 +96,7 @@ from .input_types import (
94
96
  DeleteProgramUserInput,
95
97
  DeleteProposalInput,
96
98
  DeleteSequenceInput,
99
+ DeleteTacFeedbackInput,
97
100
  InsertSmartGcalInput,
98
101
  LinkUserInput,
99
102
  RecordDatasetInput,
@@ -119,6 +122,7 @@ from .input_types import (
119
122
  SetProgramReferenceInput,
120
123
  SetProgramResourceLimitInput,
121
124
  SetProposalStatusInput,
125
+ SetTacFeedbackInput,
122
126
  UnlinkUserInput,
123
127
  UpdateAsterismsInput,
124
128
  UpdateAttachmentsInput,
@@ -777,6 +781,38 @@ class Mutation:
777
781
  field_name="setAllocations", arguments=cleared_arguments
778
782
  )
779
783
 
784
+ @classmethod
785
+ def set_tac_feedback(cls, input: SetTacFeedbackInput) -> TacFeedbackResultFields:
786
+ """Sets, or updates, a partner's TAC feedback for a program. Feedback may only
787
+ be provided by partners with a non-zero time split in the proposal. NGO users
788
+ may only set feedback for their own partner, and only for programs they can
789
+ read."""
790
+ arguments: dict[str, dict[str, Any]] = {
791
+ "input": {"type": "SetTacFeedbackInput!", "value": input}
792
+ }
793
+ cleared_arguments = {
794
+ key: value for key, value in arguments.items() if value["value"] is not None
795
+ }
796
+ return TacFeedbackResultFields(
797
+ field_name="setTacFeedback", arguments=cleared_arguments
798
+ )
799
+
800
+ @classmethod
801
+ def delete_tac_feedback(
802
+ cls, input: DeleteTacFeedbackInput
803
+ ) -> DeleteTacFeedbackResultFields:
804
+ """Deletes a partner's TAC feedback for a program. NGO users may only delete
805
+ feedback for their own partner, and only for programs they can read."""
806
+ arguments: dict[str, dict[str, Any]] = {
807
+ "input": {"type": "DeleteTacFeedbackInput!", "value": input}
808
+ }
809
+ cleared_arguments = {
810
+ key: value for key, value in arguments.items() if value["value"] is not None
811
+ }
812
+ return DeleteTacFeedbackResultFields(
813
+ field_name="deleteTacFeedback", arguments=cleared_arguments
814
+ )
815
+
780
816
  @classmethod
781
817
  def set_guide_target_name(
782
818
  cls, input: SetGuideTargetNameInput