opentideconstants 0.0.0 → 0.1.0
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.
- checksums.yaml +4 -4
- data/README.md +132 -3
- data/lib/opentideconstants/bgzf.rb +436 -0
- data/lib/opentideconstants/cache.rb +559 -0
- data/lib/opentideconstants/cache_json.rb +67 -0
- data/lib/opentideconstants/canonical.rb +756 -0
- data/lib/opentideconstants/canonical_types.rb +2537 -0
- data/lib/opentideconstants/client.rb +1135 -0
- data/lib/opentideconstants/downloader.rb +400 -0
- data/lib/opentideconstants/errors.rb +210 -0
- data/lib/opentideconstants/fold.rb +24 -0
- data/lib/opentideconstants/historical_fingerprint.rb +58 -0
- data/lib/opentideconstants/http.rb +483 -0
- data/lib/opentideconstants/models.rb +635 -0
- data/lib/opentideconstants/name_fold.json +949 -0
- data/lib/opentideconstants/predict/astro.rb +85 -0
- data/lib/opentideconstants/predict/daily-facts.json +1 -0
- data/lib/opentideconstants/predict/daily.rb +62 -0
- data/lib/opentideconstants/predict/engine.rb +506 -0
- data/lib/opentideconstants/predict/harmonic.rb +228 -0
- data/lib/opentideconstants/predict/local.rb +49 -0
- data/lib/opentideconstants/predict/results.rb +357 -0
- data/lib/opentideconstants/predict/retained.rb +487 -0
- data/lib/opentideconstants/predict.rb +192 -0
- data/lib/opentideconstants/reader.rb +493 -0
- data/lib/opentideconstants/release.rb +1531 -0
- data/lib/opentideconstants/version.rb +15 -0
- data/lib/opentideconstants.rb +24 -3
- data/supported-formats.json +5 -0
- metadata +37 -5
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
require_relative '../opentideconstants'
|
|
2
|
+
require_relative 'canonical_types'
|
|
3
|
+
|
|
4
|
+
class OpenTideConstants
|
|
5
|
+
# Every unfinished seam refuses before acquisition or mathematical decisions.
|
|
6
|
+
class Canonical
|
|
7
|
+
include OpenTideConstants.const_get(:ConstructorArguments, false)
|
|
8
|
+
include OpenTideConstants::Release.const_get(:QueryArguments, false)
|
|
9
|
+
class Unimplemented < StandardError
|
|
10
|
+
attr_reader :behavior_id
|
|
11
|
+
|
|
12
|
+
def initialize(behavior_id)
|
|
13
|
+
@behavior_id = behavior_id.freeze
|
|
14
|
+
super("Private canonical construction only: #{behavior_id} body is unimplemented")
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def prepare_member_validation_context(arguments:, native_receiver:)
|
|
21
|
+
fields = { member_id: arguments.member_id, native_profile: "ruby", native_receiver: native_receiver, prepared_receiver: native_receiver }
|
|
22
|
+
validate_native_receiver(arguments, CanonicalTypes::MemberValidationContext.new(**fields))
|
|
23
|
+
if %w[Release.heights Release.heights_at Release.extremes Release.currents Release.current_events Release.datums Release.ranges].include?(arguments.member_id)
|
|
24
|
+
native_receiver.__send__(:check_open!)
|
|
25
|
+
validate_prediction_times(arguments)
|
|
26
|
+
fields[:prepared_station] = Predict.station_for(native_receiver, arguments.station)
|
|
27
|
+
fields[:prepared_station_request] = arguments.station
|
|
28
|
+
elsif arguments.member_id.start_with?("AstroTable.")
|
|
29
|
+
Predict.instant(arguments.at) if arguments.member_id == "AstroTable.equilibrium_argument"
|
|
30
|
+
fields[:prepared_row] = native_receiver.__send__(:row_for, arguments.name)
|
|
31
|
+
fields[:prepared_row_name] = arguments.name
|
|
32
|
+
elsif arguments.member_id == "Release.attribution"
|
|
33
|
+
stations = argument_value(arguments, :stations, nil)
|
|
34
|
+
if stations.is_a?(Array)
|
|
35
|
+
fields[:prepared_attribution_request] = stations
|
|
36
|
+
fields[:prepared_attribution_steps] = []
|
|
37
|
+
stations.each do |station|
|
|
38
|
+
break unless station.is_a?(Station)
|
|
39
|
+
begin
|
|
40
|
+
entry = native_receiver.__send__(:validate_attribution_station_owner, station)
|
|
41
|
+
fields[:prepared_attribution_steps] << CanonicalTypes::PreparedAttributionStep.new(station: station, entry: entry, error: nil)
|
|
42
|
+
rescue Error => error
|
|
43
|
+
fields[:prepared_attribution_steps] << CanonicalTypes::PreparedAttributionStep.new(station: station, entry: nil, error: error)
|
|
44
|
+
break
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
CanonicalTypes::MemberValidationContext.new(**fields)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def validate_native_receiver(arguments, context)
|
|
53
|
+
guarded_client = %w[Client.releases Client.latest Client.check_for_update Client.update Client.download Client.verify Client.cached_releases Client.prune].include?(arguments.member_id)
|
|
54
|
+
guarded_release = arguments.member_id.start_with?("Release.")
|
|
55
|
+
return unless guarded_client || guarded_release
|
|
56
|
+
expected = guarded_client ? OpenTideConstants : Release
|
|
57
|
+
unless context.is_a?(CanonicalTypes::MemberValidationContext) && context.native_profile == "ruby" && context.native_receiver.is_a?(expected)
|
|
58
|
+
raise Unimplemented.new("validate_operation_arguments requires genuine native receiver prerequisite")
|
|
59
|
+
end
|
|
60
|
+
context.native_receiver.__send__(:check_open!)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def validate_prediction_times(arguments)
|
|
64
|
+
if %w[Release.heights Release.heights_at Release.extremes Release.currents Release.current_events].include?(arguments.member_id)
|
|
65
|
+
default = %w[Release.currents Release.current_events].include?(arguments.member_id) ? "m/s" : "meters"
|
|
66
|
+
Predict.validate_units(argument_value(arguments, :units, default), default)
|
|
67
|
+
end
|
|
68
|
+
if arguments.member_id == "Release.heights_at"
|
|
69
|
+
raise InvalidArgumentError, "times must be an Array of Time" unless arguments.times.is_a?(Array)
|
|
70
|
+
arguments.times.each { |time| Predict.instant(time) }
|
|
71
|
+
elsif %w[Release.heights Release.extremes Release.currents Release.current_events].include?(arguments.member_id)
|
|
72
|
+
cadence = %w[Release.heights Release.currents].include?(arguments.member_id) ? argument_value(arguments, :step_s, 600) : nil
|
|
73
|
+
Predict.window(arguments.start, arguments.stop, cadence)
|
|
74
|
+
if %w[Release.heights Release.currents].include?(arguments.member_id)
|
|
75
|
+
raise InvalidArgumentError, "step_s must be a positive integer" unless cadence.is_a?(Integer) && cadence > 0
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def require_prepared_station(arguments, context)
|
|
81
|
+
unless context.is_a?(CanonicalTypes::MemberValidationContext) && context.prepared_receiver.equal?(context.native_receiver) && context.prepared_station.is_a?(Station)
|
|
82
|
+
raise Unimplemented.new("validate_operation_arguments requires genuine lookup_station_identity/access_raw_record station resolution")
|
|
83
|
+
end
|
|
84
|
+
request = context.prepared_station_request
|
|
85
|
+
matches = arguments.station.is_a?(Station) ? request.equal?(arguments.station) : request == arguments.station
|
|
86
|
+
unless matches && context.prepared_station.instance_variable_get(:@origin).equal?(context.native_receiver.__send__(:station_origin)) && context.prepared_station.station_id == (request.is_a?(Station) ? request.station_id : request)
|
|
87
|
+
raise Unimplemented.new("validate_operation_arguments mismatched prepared lookup_station_identity/access_raw_record station binding")
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def require_prepared_astro_row(arguments, context)
|
|
92
|
+
unless context.is_a?(CanonicalTypes::MemberValidationContext) && context.native_receiver.is_a?(AstroTable) && context.prepared_receiver.equal?(context.native_receiver) && context.prepared_row_name == arguments.name && context.prepared_row && context.native_receiver.instance_variable_get(:@raw).fetch("constituents")[arguments.name].equal?(context.prepared_row)
|
|
93
|
+
raise Unimplemented.new("validate_operation_arguments requires genuine evaluate_astronomy row resolution")
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def validate_operation_arguments(operation:, arguments:, member_contract:)
|
|
98
|
+
unless member_contract.member_id == arguments.member_id
|
|
99
|
+
raise Unimplemented.new("validate_operation_arguments mismatched native member #{arguments.member_id}")
|
|
100
|
+
end
|
|
101
|
+
validate_native_receiver(arguments, member_contract)
|
|
102
|
+
case arguments.member_id
|
|
103
|
+
when "Client.open"
|
|
104
|
+
constructor_options(**client_option_keywords(arguments), environment: {})
|
|
105
|
+
HTTP.validate_proxy_argument(argument_value(arguments, :proxy, nil))
|
|
106
|
+
when "Client.download"
|
|
107
|
+
check_release_arg(arguments.release)
|
|
108
|
+
destination = arguments.to
|
|
109
|
+
raise InvalidArgumentError, "to must be a String path" unless destination.is_a?(String) && !destination.empty?
|
|
110
|
+
formats = argument_value(arguments, :formats, [:jsonl])
|
|
111
|
+
raise InvalidArgumentError, "formats must be an Array" unless formats.is_a?(Array) && !formats.empty?
|
|
112
|
+
formats.map { |format| check_enum(format, FORMATS, "format") }.uniq
|
|
113
|
+
check_bool(argument_value(arguments, :overwrite, false), "overwrite")
|
|
114
|
+
when "Client.prune"
|
|
115
|
+
keep = argument_value(arguments, :keep, 3)
|
|
116
|
+
raise InvalidArgumentError, "keep must be an Integer >= 0" unless keep.is_a?(Integer) && keep >= 0
|
|
117
|
+
when "Release.station", "Release.require_station", "Release.tombstone"
|
|
118
|
+
check_id!(arguments.station_id)
|
|
119
|
+
when "Release.station_by_alias"
|
|
120
|
+
validate_alias_arguments(arguments.system, arguments.alias_id)
|
|
121
|
+
when "Release.search"
|
|
122
|
+
validate_search_arguments(arguments.name, argument_value(arguments, :limit, nil), argument_value(arguments, :match, nil))
|
|
123
|
+
validate_filter_arguments(argument_value(arguments, :filters, {}))
|
|
124
|
+
when "Release.bbox"
|
|
125
|
+
validate_bbox_arguments(arguments.south, arguments.west, arguments.north, arguments.east, argument_value(arguments, :limit, nil))
|
|
126
|
+
validate_filter_arguments(argument_value(arguments, :filters, {}))
|
|
127
|
+
when "Release.near"
|
|
128
|
+
validate_near_arguments(arguments.lat, arguments.lon, arguments.radius_km, argument_value(arguments, :limit, nil))
|
|
129
|
+
validate_filter_arguments(argument_value(arguments, :filters, {}))
|
|
130
|
+
when "Release.nearest"
|
|
131
|
+
validate_nearest_arguments(arguments.lat, arguments.lon, argument_value(arguments, :max_km, nil))
|
|
132
|
+
validate_filter_arguments(argument_value(arguments, :filters, {}))
|
|
133
|
+
when "Release.stations", "Release.iter_stations"
|
|
134
|
+
validate_filter_arguments(argument_value(arguments, :filters, {}))
|
|
135
|
+
when "Station.constant_sets"
|
|
136
|
+
check_bool(argument_value(arguments, :include_no_constants, false), "include_no_constants")
|
|
137
|
+
when "Release.attribution"
|
|
138
|
+
stations = argument_value(arguments, :stations, nil)
|
|
139
|
+
raise InvalidArgumentError, "stations must be an Array of Station" unless stations.nil? || stations.is_a?(Array)
|
|
140
|
+
Array(stations).each_with_index do |station, index|
|
|
141
|
+
raise InvalidArgumentError, "stations must be an Array of Station" unless station.is_a?(Station)
|
|
142
|
+
step = member_contract.prepared_attribution_steps[index]
|
|
143
|
+
unless member_contract.prepared_receiver.equal?(member_contract.native_receiver) && member_contract.prepared_attribution_request.equal?(stations) && step && step.station.equal?(station)
|
|
144
|
+
raise Unimplemented.new("validate_operation_arguments requires genuine staged access_raw_record attribution owner outcome")
|
|
145
|
+
end
|
|
146
|
+
raise step.error if step.error
|
|
147
|
+
raise Unimplemented.new("validate_operation_arguments missing genuine staged access_raw_record Entry") unless step.entry
|
|
148
|
+
end
|
|
149
|
+
when "Release.reference_station", "Release.subordinates_of"
|
|
150
|
+
raise InvalidArgumentError, "#{operation}: station must be a Station" unless arguments.station.is_a?(Station)
|
|
151
|
+
when "Release.heights", "Release.currents", "Release.extremes", "Release.current_events"
|
|
152
|
+
validate_prediction_times(arguments)
|
|
153
|
+
require_prepared_station(arguments, member_contract)
|
|
154
|
+
if %w[Release.currents Release.current_events].include?(arguments.member_id)
|
|
155
|
+
Predict.options(argument_value(arguments, :set_id, nil), nil, argument_value(arguments, :bin_number, nil))
|
|
156
|
+
else
|
|
157
|
+
Predict.options(argument_value(arguments, :set_id, nil), argument_value(arguments, :datum, nil))
|
|
158
|
+
offset_id = argument_value(arguments, :offset_id, nil)
|
|
159
|
+
raise InvalidArgumentError, "offset_id must be a string" unless offset_id.nil? || offset_id.is_a?(String)
|
|
160
|
+
raise InvalidArgumentError, "set_id and offset_id are mutually exclusive" if offset_id && argument_value(arguments, :set_id, nil)
|
|
161
|
+
end
|
|
162
|
+
when "Release.heights_at"
|
|
163
|
+
validate_prediction_times(arguments)
|
|
164
|
+
require_prepared_station(arguments, member_contract)
|
|
165
|
+
Predict.options(argument_value(arguments, :set_id, nil), argument_value(arguments, :datum, nil))
|
|
166
|
+
offset_id = argument_value(arguments, :offset_id, nil)
|
|
167
|
+
raise InvalidArgumentError, "offset_id must be a string" unless offset_id.nil? || offset_id.is_a?(String)
|
|
168
|
+
raise InvalidArgumentError, "set_id and offset_id are mutually exclusive" if offset_id && argument_value(arguments, :set_id, nil)
|
|
169
|
+
when "Release.datums", "Release.ranges"
|
|
170
|
+
require_prepared_station(arguments, member_contract)
|
|
171
|
+
Predict.options(argument_value(arguments, :set_id, nil))
|
|
172
|
+
if arguments.member_id == "Release.datums"
|
|
173
|
+
all_sets = argument_value(arguments, :all_sets, false)
|
|
174
|
+
raise InvalidArgumentError, "all_sets must be a boolean" unless all_sets == true || all_sets == false
|
|
175
|
+
end
|
|
176
|
+
when "Release.astro_table"
|
|
177
|
+
id = argument_value(arguments, :id, nil)
|
|
178
|
+
raise InvalidArgumentError, "astro table id must be a string" unless id.nil? || id.is_a?(String)
|
|
179
|
+
when "AstroTable.equilibrium_argument"
|
|
180
|
+
Predict.instant(arguments.at)
|
|
181
|
+
require_prepared_astro_row(arguments, member_contract)
|
|
182
|
+
when "AstroTable.node_factor"
|
|
183
|
+
require_prepared_astro_row(arguments, member_contract)
|
|
184
|
+
Predict.instant(arguments.at)
|
|
185
|
+
when "AstroTable.equilibrium_for_year", "AstroTable.node_factor_for_year"
|
|
186
|
+
require_prepared_astro_row(arguments, member_contract)
|
|
187
|
+
member_contract.native_receiver.__send__(:validate_year_argument, arguments.year)
|
|
188
|
+
end
|
|
189
|
+
arguments
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def resolve_effective_options(explicit_options:, environment:, platform_defaults:)
|
|
193
|
+
options = client_option_keywords(explicit_options, platform_defaults)
|
|
194
|
+
resolved = constructor_options(**options, environment: environment)
|
|
195
|
+
CanonicalTypes::ArgsClientOpen.new(
|
|
196
|
+
member_id: "Client.open", release: resolved.requested, file: options.fetch(:file, nil),
|
|
197
|
+
cache_dir: resolved.cache_dir, offline: resolved.offline, mode: resolved.mode,
|
|
198
|
+
base_url: resolved.base_url, timeout: options.fetch(:timeout, nil), proxy: options.fetch(:proxy, nil),
|
|
199
|
+
ca_file: options.fetch(:ca_file, nil), user_agent: options.fetch(:user_agent, nil),
|
|
200
|
+
on_network_error: resolved.on_network_error, auto_update: resolved.auto_update,
|
|
201
|
+
update_interval: resolved.update_interval, logger: resolved.logger,
|
|
202
|
+
verify_on_open: resolved.verify_on_open, commercial_only: resolved.commercial_only,
|
|
203
|
+
commercial_basis: resolved.commercial_basis.to_s, historical_offsets_policy: resolved.historical_offsets_policy.to_s
|
|
204
|
+
)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def select_canonical_error(operation:, ordered_failures:, cause:)
|
|
208
|
+
failure = ordered_failures.first || (raise Unimplemented.new("select_canonical_error no selected failure for #{operation}"))
|
|
209
|
+
return failure if failure.cause || cause.nil?
|
|
210
|
+
CanonicalTypes::CanonicalError.new(code: failure.code, structured_fields: failure.structured_fields, cause: cause)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def translate_native_binding(canonical_result: CanonicalTypes::ABSENT, canonical_error: CanonicalTypes::ABSENT, native_profile:)
|
|
214
|
+
raise Unimplemented.new("translate_native_binding #{native_profile}") unless native_profile == "ruby"
|
|
215
|
+
present = !canonical_result.equal?(CanonicalTypes::ABSENT)
|
|
216
|
+
if !canonical_error.equal?(CanonicalTypes::ABSENT)
|
|
217
|
+
error = canonical_error.cause
|
|
218
|
+
if present && canonical_result.value.is_a?(OpenTideConstants) && canonical_result.value.last_error.equal?(error)
|
|
219
|
+
return canonical_result.value
|
|
220
|
+
end
|
|
221
|
+
raise error if error.is_a?(OpenTideConstants::Error)
|
|
222
|
+
raise Unimplemented.new("translate_native_binding missing original native error")
|
|
223
|
+
end
|
|
224
|
+
raise Unimplemented.new("translate_native_binding absent result and error") unless present
|
|
225
|
+
canonical_result.value.is_a?(CanonicalTypes::NoValue) ? nil : canonical_result.value
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def decode_release_document(source_bytes:, reader_version:, document_kind:)
|
|
229
|
+
require_native_reader_version(reader_version)
|
|
230
|
+
if document_kind == "station_row" && reader_version.native_context.is_a?(Release)
|
|
231
|
+
# Keep the native lazy parser's error text and the subsequent
|
|
232
|
+
# owner's check_line! boundary, rather than moving its guards.
|
|
233
|
+
raw, why = reader_version.native_context.__send__(:parse_station, source_bytes.dup)
|
|
234
|
+
raise InvalidReleaseError, why if why
|
|
235
|
+
return raw
|
|
236
|
+
end
|
|
237
|
+
document = Reader.parse_json(source_bytes.dup.force_encoding(Encoding::UTF_8))
|
|
238
|
+
case document_kind
|
|
239
|
+
when "release"
|
|
240
|
+
Release.check_format!(document)
|
|
241
|
+
when "station_row"
|
|
242
|
+
raise InvalidReleaseError, "a station is not an object" unless document.is_a?(Hash)
|
|
243
|
+
if document["status"] == "removed"
|
|
244
|
+
Release.check_tombstone!(document)
|
|
245
|
+
elsif document["status"].nil? || document["status"] == "active"
|
|
246
|
+
Release.check_station!(document)
|
|
247
|
+
end
|
|
248
|
+
when "pointer"
|
|
249
|
+
OpenTideConstants.allocate.__send__(:check_entry!, document, "OTC_latest.json")
|
|
250
|
+
when "catalogue"
|
|
251
|
+
OpenTideConstants.allocate.__send__(:index_entries, document)
|
|
252
|
+
when "cache"
|
|
253
|
+
# The caller's cache-kind admission is separate from decoding.
|
|
254
|
+
# Cache documents keep their exact optional/unknown fields.
|
|
255
|
+
else
|
|
256
|
+
raise Unimplemented.new("decode_release_document unsupported document kind #{document_kind}")
|
|
257
|
+
end
|
|
258
|
+
document
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
def require_native_reader_version(version)
|
|
262
|
+
declared = "#{version.major}.#{version.minor}"
|
|
263
|
+
raise Unimplemented.new("decode_release_document requires the native Ruby reader version") unless declared == SUPPORTED_FORMAT_VERSION
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def validate_release_links(parsed_document:, required_links:)
|
|
267
|
+
Release.check_format!(parsed_document)
|
|
268
|
+
stations = parsed_document["stations"]
|
|
269
|
+
raise InvalidReleaseError, "stations missing" unless stations.is_a?(Array)
|
|
270
|
+
graph = Release.allocate
|
|
271
|
+
graph.__send__(:prepare_release_fields, meta: parsed_document.reject { |key, _| key == "stations" }, mode: :eager, files: [], checks: {})
|
|
272
|
+
graph.__send__(:load_stations, stations.map { |station| [station, nil, nil] })
|
|
273
|
+
graph.__send__(:close)
|
|
274
|
+
parsed_document
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def materialize_typed_model(raw_fields:, field_contract:, origin:, model_type:)
|
|
278
|
+
context = field_contract.native_context
|
|
279
|
+
case model_type
|
|
280
|
+
when "Station"
|
|
281
|
+
unless context.is_a?(Station) && raw_fields["station_id"] == context.station_id && raw_fields.fetch("constant_sets", []) == context.instance_variable_get(:@sets).map(&:raw) && raw_fields["validation"] == context.raw["validation"]
|
|
282
|
+
raise Unimplemented.new("materialize_typed_model Station raw fields disagree with prepared native dependencies")
|
|
283
|
+
end
|
|
284
|
+
Station.new(raw_fields, sets: context.instance_variable_get(:@sets), kind: context.kind,
|
|
285
|
+
validation: context.validation, origin: origin, licences: origin.licences.to_h { |licence| [licence.licence_id, licence] })
|
|
286
|
+
when "ConstantSet"
|
|
287
|
+
unless context.is_a?(ConstantSet) && raw_fields["set_id"] == context.set_id && raw_fields["convention_id"] == context.convention&.convention_id && raw_fields["licence_id"] == context.licence&.licence_id
|
|
288
|
+
raise Unimplemented.new("materialize_typed_model ConstantSet raw fields disagree with prepared native dependencies")
|
|
289
|
+
end
|
|
290
|
+
ConstantSet.new(raw_fields, convention: context.convention, licence: context.licence,
|
|
291
|
+
validation: context.validation, recommended: context.recommended?)
|
|
292
|
+
when "SourceRecord"
|
|
293
|
+
SourceRecord.new(raw_fields, licences: origin.licences.to_h { |licence| [licence.licence_id, licence] })
|
|
294
|
+
when "ReleaseInfo"
|
|
295
|
+
ReleaseInfo.new(raw_fields, context.files)
|
|
296
|
+
when "FileInfo"
|
|
297
|
+
FileInfo.new(name: raw_fields.fetch("name"), url: raw_fields["url"], size: raw_fields["size"], sha256: raw_fields["sha256"])
|
|
298
|
+
when "Nearby"
|
|
299
|
+
Nearby.new(context.station, raw_fields.fetch("distance_km"))
|
|
300
|
+
when "UpdateResult"
|
|
301
|
+
UpdateResult.new(raw_fields.fetch("updated"), raw_fields.fetch("from"), raw_fields.fetch("to"))
|
|
302
|
+
when "Stats"
|
|
303
|
+
Stats.new(type: raw_fields.fetch("type").transform_keys { |key| Util.enum(key, ENUMS[:station_type]) }.freeze,
|
|
304
|
+
kind: raw_fields.fetch("kind").transform_keys { |key| Util.enum(key, ENUMS[:kind]) }.freeze,
|
|
305
|
+
country: raw_fields.fetch("country").freeze, source: raw_fields.fetch("source").freeze,
|
|
306
|
+
qc_status: raw_fields.fetch("qc_status").transform_keys { |key| Util.enum(key, ENUMS[:qc_status]) }.freeze)
|
|
307
|
+
when "Client"
|
|
308
|
+
raise Unimplemented.new("materialize_typed_model Client requires closed prepared owner fields") unless context.is_a?(CanonicalTypes::PreparedClientFields)
|
|
309
|
+
if raw_fields.key?("loaded_from") && raw_fields["loaded_from"] != context.loaded_from.to_s
|
|
310
|
+
raise Unimplemented.new("materialize_typed_model Client raw loaded_from disagrees with prepared owner")
|
|
311
|
+
end
|
|
312
|
+
if raw_fields.key?("newer_format_major") && raw_fields["newer_format_major"] != context.newer_format_major
|
|
313
|
+
raise Unimplemented.new("materialize_typed_model Client raw newer_format_major disagrees with prepared owner")
|
|
314
|
+
end
|
|
315
|
+
if raw_fields.key?("last_error") && raw_fields["last_error"].nil? && context.last_error
|
|
316
|
+
raise Unimplemented.new("materialize_typed_model Client raw last_error disagrees with prepared owner")
|
|
317
|
+
end
|
|
318
|
+
if raw_fields["last_error"]
|
|
319
|
+
raw_error = raw_fields["last_error"]
|
|
320
|
+
unless context.last_error && raw_error.is_a?(Hash) && raw_error["code"] == context.last_error.code && raw_error["message"] == context.last_error.message
|
|
321
|
+
raise Unimplemented.new("materialize_typed_model Client raw last_error fields disagree with prepared owner")
|
|
322
|
+
end
|
|
323
|
+
end
|
|
324
|
+
receiver = OpenTideConstants.allocate
|
|
325
|
+
receiver.__send__(:bind_prepared_client_fields, context)
|
|
326
|
+
receiver
|
|
327
|
+
when "Release"
|
|
328
|
+
raise Unimplemented.new("materialize_typed_model Release requires independent prepared owner fields") unless context.is_a?(CanonicalTypes::PreparedReleaseFields)
|
|
329
|
+
raise Unimplemented.new("materialize_typed_model Release raw metadata disagrees with prepared fields") unless raw_fields == context.meta
|
|
330
|
+
if origin.is_a?(Release)
|
|
331
|
+
unless !context.state.equal?(origin.instance_variable_get(:@state)) && !context.station_cache.equal?(origin.instance_variable_get(:@station_cache)) && !context.io_lock.equal?(origin.instance_variable_get(:@io_lock)) && !context.station_cache_lock.equal?(origin.instance_variable_get(:@station_cache_lock)) && (context.io.nil? || !context.io.equal?(origin.instance_variable_get(:@io)))
|
|
332
|
+
raise Unimplemented.new("materialize_typed_model Release requires independent state/cache/locks/IO")
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
unless context.entries.all? { |entry| context.by_id[entry.station_id].equal?(entry) } && context.subordinates.values.flatten.all? { |entry| context.by_id[entry.station_id].equal?(entry) }
|
|
336
|
+
raise Unimplemented.new("materialize_typed_model Release prepared indexes disagree on Entry owners")
|
|
337
|
+
end
|
|
338
|
+
receiver = Release.allocate
|
|
339
|
+
receiver.__send__(:bind_prepared_release_fields, context)
|
|
340
|
+
receiver.__send__(:bind_eager_station_owners, context.entries, context.raws)
|
|
341
|
+
context.entries.freeze
|
|
342
|
+
context.by_id.freeze
|
|
343
|
+
receiver.freeze
|
|
344
|
+
when "Licence", "Convention", "Constituent", "Provenance", "ProvenanceBuild", "TimeBase", "QcFlag",
|
|
345
|
+
"DroppedConstituent", "Validation", "SubordinateOffsets", "RecordSpan", "Datum", "AstroTable", "Fallback",
|
|
346
|
+
"HistoricalOffsetVintage", "HistoricalOffsetProvenance", "Tombstone"
|
|
347
|
+
OpenTideConstants.const_get(model_type, false).new(raw_fields)
|
|
348
|
+
when "HeightPoint"
|
|
349
|
+
HeightPoint.new(**result_field_inputs(raw_fields, context, %w[units height_m local_time utc_offset_s], time: true))
|
|
350
|
+
when "Extreme"
|
|
351
|
+
fields = result_field_inputs(raw_fields, context, %w[units type height_m local_time utc_offset_s], time: true)
|
|
352
|
+
fields[:type] = Util.enum(fields[:type], ENUMS[:extreme_type]) if fields.key?(:type)
|
|
353
|
+
Extreme.new(**fields)
|
|
354
|
+
when "CurrentPoint"
|
|
355
|
+
CurrentPoint.new(**result_field_inputs(raw_fields, context, %w[units velocity_major_ms velocity_minor_ms speed_ms direction_deg local_time utc_offset_s], time: true))
|
|
356
|
+
when "CurrentEvent"
|
|
357
|
+
fields = result_field_inputs(raw_fields, context, %w[units type velocity_ms direction_deg local_time utc_offset_s], time: true)
|
|
358
|
+
fields[:type] = Util.enum(fields[:type], ENUMS[:current_event_type]) if fields.key?(:type)
|
|
359
|
+
CurrentEvent.new(**fields)
|
|
360
|
+
when "HeightSeries", "ExtremeList"
|
|
361
|
+
fields = %w[requested_profile resolved_profile selection_status selection_evidence source units station_id timezone method set_id convention_id astro_table_id reference_station_id reference_bin datum datum_name datum_kind datum_uncertainty_m tz tz_version release algorithm offset_id offset_source offset_source_version historical_offsets current_validity current_accuracy reference_set_id reference_source_version reference_2020_equivalence source_note]
|
|
362
|
+
keywords = result_field_inputs(raw_fields, context, fields, collection: :items)
|
|
363
|
+
keywords[:method] = Util.enum(keywords[:method], ENUMS[:prediction_method]) if keywords.key?(:method)
|
|
364
|
+
model_type == "HeightSeries" ? HeightSeries.new(**keywords) : ExtremeList.new(**keywords)
|
|
365
|
+
when "CurrentSeries"
|
|
366
|
+
fields = result_field_inputs(raw_fields, context, %w[requested_profile resolved_profile selection_status selection_evidence source units station_id timezone method set_id convention_id astro_table_id reference_station_id reference_bin datum datum_name datum_kind datum_uncertainty_m bin_number tz tz_version release algorithm], collection: :items)
|
|
367
|
+
fields[:method] = Util.enum(fields[:method], ENUMS[:prediction_method]) if fields.key?(:method)
|
|
368
|
+
CurrentSeries.new(**fields)
|
|
369
|
+
when "CurrentEventList"
|
|
370
|
+
fields = result_field_inputs(raw_fields, context, %w[requested_profile resolved_profile selection_status selection_evidence source units station_id timezone method set_id convention_id astro_table_id reference_station_id reference_bin datum datum_name datum_kind datum_uncertainty_m bin_number omitted_event_types tz tz_version release algorithm], collection: :items)
|
|
371
|
+
fields[:method] = Util.enum(fields[:method], ENUMS[:prediction_method]) if fields.key?(:method)
|
|
372
|
+
if fields[:omitted_event_types]
|
|
373
|
+
fields[:omitted_event_types] = fields[:omitted_event_types].map { |type| Util.enum(type, ENUMS[:current_event_type]) }
|
|
374
|
+
end
|
|
375
|
+
CurrentEventList.new(**fields)
|
|
376
|
+
when "DatumInfo"
|
|
377
|
+
DatumInfo.new(**result_field_inputs(raw_fields, context, %w[set_id zero zero_name chart_datum msl_offset_m], collection: :levels))
|
|
378
|
+
when "DatumLevel"
|
|
379
|
+
DatumLevel.new(**result_field_inputs(raw_fields, context, %w[key value_m above_chart_m kind method source_name epoch data_span control_station_id control_set_id control_source_id uncertainty_m uncertainty_basis flags]))
|
|
380
|
+
when "Ranges"
|
|
381
|
+
Ranges.new(**result_field_inputs(raw_fields, context, %w[mn gt dhq dlq]))
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
def result_field_inputs(raw_fields, context, scalar_fields, time: false, collection: nil)
|
|
386
|
+
values = scalar_fields.each_with_object({}) do |field, result|
|
|
387
|
+
result[field.to_sym] = raw_fields[field] if raw_fields.key?(field)
|
|
388
|
+
end
|
|
389
|
+
if time && raw_fields.key?("time")
|
|
390
|
+
native_time = raw_fields["time"].nil? ? nil : context.time
|
|
391
|
+
unless Util.time(raw_fields["time"]) == native_time
|
|
392
|
+
raise Unimplemented.new("materialize_typed_model mismatched prepared Time")
|
|
393
|
+
end
|
|
394
|
+
values[:time] = native_time
|
|
395
|
+
end
|
|
396
|
+
if collection && raw_fields.key?(collection.to_s)
|
|
397
|
+
raw = raw_fields[collection.to_s]
|
|
398
|
+
native = raw.nil? ? nil : (raw.empty? ? [] : context.public_send(collection))
|
|
399
|
+
unless raw.nil? || raw.length == native.length && raw.zip(native).all? { |row, item| row.all? { |field, value| result_field_matches?(item.public_send(field), value) } }
|
|
400
|
+
raise Unimplemented.new("materialize_typed_model mismatched prepared #{collection}")
|
|
401
|
+
end
|
|
402
|
+
values[collection] = native
|
|
403
|
+
end
|
|
404
|
+
values[:_local] = context&.instance_variable_get(:@_local)
|
|
405
|
+
values
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
def result_field_matches?(native, raw)
|
|
409
|
+
return Util.time(raw) == native if native.is_a?(Time)
|
|
410
|
+
return native.to_s == raw if native.is_a?(Symbol)
|
|
411
|
+
native == raw
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
def access_raw_record(access_kind:, source_record:, station:, release_origin:, native_profile:)
|
|
415
|
+
case access_kind
|
|
416
|
+
when "raw_record"
|
|
417
|
+
retain_raw_source_record(source_record: source_record, native_profile: native_profile)
|
|
418
|
+
when "station_object"
|
|
419
|
+
check_station_origin(station: station, release_origin: release_origin)
|
|
420
|
+
else
|
|
421
|
+
raise Unimplemented.new("access_raw_record unsupported access kind #{access_kind}")
|
|
422
|
+
end
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
def open_client_release(arguments:, environment:, platform_defaults:, cache_state:, clock:, native_profile:, reader_version:)
|
|
426
|
+
raise Unimplemented.new("open_client_release")
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
def resolve_release_request(release_request:, effective_options:, cache_state:, clock:, reader_version:)
|
|
430
|
+
raise Unimplemented.new("resolve_release_request")
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def exchange_release_metadata(metadata_request:, trusted_cache:, transport_options:, cache_state:, clock:, reader_version:)
|
|
434
|
+
raise Unimplemented.new("exchange_release_metadata")
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
def update_client_release(client_state:, update_request:, clock:, reader_version:)
|
|
438
|
+
raise Unimplemented.new("update_client_release")
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
def refresh_client_if_due(client_state:, query_kind:, clock:, reader_version:)
|
|
442
|
+
raise Unimplemented.new("refresh_client_if_due")
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
def forward_held_release(held_release:, query_arguments:)
|
|
446
|
+
raise Unimplemented.new("forward_held_release")
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
def enforce_resource_lifetime(resource_state:, lifetime_action:)
|
|
450
|
+
owner = resource_state.is_a?(CanonicalTypes::StreamReader) ? resource_state.release_view : resource_state
|
|
451
|
+
unless owner.is_a?(OpenTideConstants) || owner.is_a?(Release)
|
|
452
|
+
raise Unimplemented.new("enforce_resource_lifetime requires genuine native resource owner")
|
|
453
|
+
end
|
|
454
|
+
if lifetime_action == "close"
|
|
455
|
+
owner.__send__(:close)
|
|
456
|
+
elsif !%w[release_metadata raw provenance last_error loaded_from newer_format_major].include?(lifetime_action)
|
|
457
|
+
owner.__send__(:check_open!)
|
|
458
|
+
end
|
|
459
|
+
resource_state
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
def bind_checksum_manifest(checksum_bytes:, pointer_digests:, required_files:)
|
|
463
|
+
path = required_files.first
|
|
464
|
+
sha_name = if checksum_bytes.is_a?(CanonicalTypes::ChecksumBytes)
|
|
465
|
+
checksum_bytes.source
|
|
466
|
+
else
|
|
467
|
+
path ? "#{Reader.parse_name(path).first}.sha256" : pointer_digests.keys.find { |name| name.end_with?(".sha256") }
|
|
468
|
+
end
|
|
469
|
+
sha_name ||= "the .sha256 file"
|
|
470
|
+
expected = pointer_digests[sha_name]
|
|
471
|
+
if expected
|
|
472
|
+
actual = Digest::SHA256.hexdigest(checksum_bytes.b)
|
|
473
|
+
unless expected.downcase == actual
|
|
474
|
+
raise ChecksumError.new("#{sha_name} does not match the pointer", file: sha_name, expected: expected.downcase, actual: actual)
|
|
475
|
+
end
|
|
476
|
+
end
|
|
477
|
+
rows = Reader.parse_sha256(checksum_bytes, sha_name)
|
|
478
|
+
Reader.need_rows!(path, required_files, rows, sha_name) if path
|
|
479
|
+
unless pointer_digests.empty?
|
|
480
|
+
entry = { "files" => pointer_digests.map { |name, digest| { "name" => name, "sha256" => digest } } }
|
|
481
|
+
Downloader.check_agreement(entry, sha_name, rows)
|
|
482
|
+
end
|
|
483
|
+
rows
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
def acquire_release_files(acquisition_descriptor:, effective_options:, load_mode:, cache_state:, clock:, reader_version:)
|
|
487
|
+
raise Unimplemented.new("acquire_release_files")
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
def merge_cache_receipt(locked_cache_state:, verified_file_rows:, release_metadata:)
|
|
491
|
+
raise Unimplemented.new("merge_cache_receipt")
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
def select_cached_release(release_candidates:, effective_options:, cache_state:, clock:)
|
|
495
|
+
raise Unimplemented.new("select_cached_release")
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
def verify_release_files(release_files:, trusted_cached_pointer:)
|
|
499
|
+
raise Unimplemented.new("verify_release_files requires genuine loaded file owner") unless release_files.is_a?(OpenTideConstants)
|
|
500
|
+
release_files.__send__(:check_open!)
|
|
501
|
+
release_files.__send__(:verify_release_integrity, canonical: self, trusted_cached_pointer: trusted_cached_pointer)
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
def publish_download(destination:, format_selection:, overwrite_policy:, release_files:, checksum_bytes:, pointer_digests:)
|
|
505
|
+
raise Unimplemented.new("publish_download")
|
|
506
|
+
end
|
|
507
|
+
|
|
508
|
+
def manage_cache_inventory(inventory_action:, cache_state:, keep:, current_cache_directory:, clock:)
|
|
509
|
+
raise Unimplemented.new("manage_cache_inventory")
|
|
510
|
+
end
|
|
511
|
+
|
|
512
|
+
def perform_guarded_io(io_kind:, io_request:, io_options:, clock:)
|
|
513
|
+
raise Unimplemented.new("perform_guarded_io")
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
def project_station_index(station_source_row:, source_byte_span:, projection_contract:)
|
|
517
|
+
Reader.index_entry(station_source_row, source_byte_span.offset_bytes, source_byte_span.length_bytes)
|
|
518
|
+
end
|
|
519
|
+
|
|
520
|
+
def authenticate_station_index(source_files:, supplied_index:, index_presence:, reader_version:)
|
|
521
|
+
owner = source_files
|
|
522
|
+
unless owner.is_a?(OpenTideConstants) && owner.instance_variable_get(:@file).nil? && owner.instance_variable_get(:@mode) == :stream
|
|
523
|
+
raise Unimplemented.new("authenticate_station_index requires genuine cached stream source owner")
|
|
524
|
+
end
|
|
525
|
+
owner.__send__(:check_open!)
|
|
526
|
+
require_native_reader_version(reader_version)
|
|
527
|
+
release = owner.instance_variable_get(:@release)
|
|
528
|
+
datestamp = release.datestamp
|
|
529
|
+
verified = owner.__send__(:cache).verified(datestamp)
|
|
530
|
+
raise Unimplemented.new("authenticate_station_index requires actual verified source files") unless verified
|
|
531
|
+
paths = release.__send__(:opened_paths)
|
|
532
|
+
opts = { mode: :stream, files: release.files, checks: release.instance_variable_get(:@checks), verify: true,
|
|
533
|
+
zenodo_version_doi: release.zenodo_version_doi, logger: owner.instance_variable_get(:@logger),
|
|
534
|
+
commercial_only: owner.instance_variable_get(:@commercial_only), commercial_basis: owner.instance_variable_get(:@commercial_basis),
|
|
535
|
+
historical_offsets_policy: owner.instance_variable_get(:@historical_offsets_policy) }
|
|
536
|
+
document = nil
|
|
537
|
+
native_release = if BGZF.declared?(verified["files"], datestamp)
|
|
538
|
+
owner.__send__(:load_cached_bgzf, datestamp, verified, canonical: self,
|
|
539
|
+
supplied_index: supplied_index, index_presence: index_presence, on_index: ->(index) { document = index })
|
|
540
|
+
else
|
|
541
|
+
owner.__send__(:load_cached_stream, datestamp, verified, paths.first, opts, canonical: self,
|
|
542
|
+
supplied_index: supplied_index, index_presence: index_presence, on_index: ->(index) { document = index })
|
|
543
|
+
end
|
|
544
|
+
Util.deep_freeze(document)
|
|
545
|
+
CanonicalTypes::AuthenticatedIndex.new(
|
|
546
|
+
index_version: document.fetch("index_version"), discovery_index_version: document.fetch("discovery_index_version", CanonicalTypes::ABSENT),
|
|
547
|
+
datestamp: document.fetch("datestamp"), jsonl: document.fetch("jsonl"), jsonl_sha256: document.fetch("jsonl_sha256"),
|
|
548
|
+
jsonl_size: document.fetch("jsonl_size"), by: document.fetch("by", CanonicalTypes::ABSENT), stations: document.fetch("stations"),
|
|
549
|
+
native_context: native_release, source_document: document)
|
|
550
|
+
end
|
|
551
|
+
|
|
552
|
+
def compare_station_source(index_entry:, station_source_row:, index_presence:)
|
|
553
|
+
owner = index_presence
|
|
554
|
+
unless owner.is_a?(Release) && index_entry.is_a?(Release::Entry) && owner.instance_variable_get(:@by_id)[index_entry.station_id].equal?(index_entry) && index_entry.view
|
|
555
|
+
raise Unimplemented.new("compare_station_source requires genuine indexed Entry and its producing Release presence")
|
|
556
|
+
end
|
|
557
|
+
owner.__send__(:check_line!, station_source_row, index_entry)
|
|
558
|
+
station_source_row
|
|
559
|
+
end
|
|
560
|
+
|
|
561
|
+
def read_station_lazily(stream_reader:, station_id:, release_origin:, reader_version:)
|
|
562
|
+
owner = stream_reader.is_a?(CanonicalTypes::StreamReader) ? stream_reader.release_view : stream_reader
|
|
563
|
+
unless owner.is_a?(Release) && release_origin.equal?(owner)
|
|
564
|
+
raise Unimplemented.new("read_station_lazily requires genuine producing Release reader context")
|
|
565
|
+
end
|
|
566
|
+
enforce_resource_lifetime(resource_state: stream_reader, lifetime_action: "station_read")
|
|
567
|
+
require_native_reader_version(reader_version)
|
|
568
|
+
if stream_reader.is_a?(CanonicalTypes::StreamReader)
|
|
569
|
+
io = owner.instance_variable_get(:@io)
|
|
570
|
+
unless io && io.fileno == stream_reader.file_descriptor && owner.instance_variable_get(:@station_cache).equal?(stream_reader.station_lru)
|
|
571
|
+
raise Unimplemented.new("read_station_lazily mismatched borrowed reader descriptor or native LRU")
|
|
572
|
+
end
|
|
573
|
+
end
|
|
574
|
+
entry = owner.instance_variable_get(:@by_id)[station_id]
|
|
575
|
+
raise StationNotFoundError, "station #{station_id} not found" unless entry
|
|
576
|
+
native_version = CanonicalTypes::ReaderVersion.new(major: reader_version.major, minor: reader_version.minor, native_context: owner)
|
|
577
|
+
owner.__send__(:materialize, entry, canonical: self, reader_version: native_version).raw
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
def lookup_station_identity(release_view:, identity_query:, reader_version:)
|
|
581
|
+
raise Unimplemented.new("lookup_station_identity")
|
|
582
|
+
end
|
|
583
|
+
|
|
584
|
+
def select_effective_recommendation(station_sets:, original_recommendation:, commercial_only:)
|
|
585
|
+
raise Unimplemented.new("select_effective_recommendation")
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
def admit_quality_path(candidate_path:, include_flagged:, include_fallback:)
|
|
589
|
+
raise Unimplemented.new("admit_quality_path")
|
|
590
|
+
end
|
|
591
|
+
|
|
592
|
+
def admit_commercial_path(candidate_path:, commercial_only:, commercial_basis:)
|
|
593
|
+
raise Unimplemented.new("admit_commercial_path")
|
|
594
|
+
end
|
|
595
|
+
|
|
596
|
+
def resolve_reference_path(station_source_row:, path_request:, release_view:)
|
|
597
|
+
raise Unimplemented.new("resolve_reference_path")
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
def execute_discovery_query(release_view:, query_kind:, query_options:, reader_version:)
|
|
601
|
+
raise Unimplemented.new("execute_discovery_query")
|
|
602
|
+
end
|
|
603
|
+
|
|
604
|
+
def summarize_station_sets(summary_kind:, release_view:, station_sets:, summary_options:)
|
|
605
|
+
raise Unimplemented.new("summarize_station_sets")
|
|
606
|
+
end
|
|
607
|
+
|
|
608
|
+
def admit_historical_offset(own_offset:, reference_path:, historical_policy:, selection_kind:, reader_version:)
|
|
609
|
+
raise Unimplemented.new("admit_historical_offset")
|
|
610
|
+
end
|
|
611
|
+
|
|
612
|
+
def format_attribution(station:, release_view:, commercial_only:)
|
|
613
|
+
raise Unimplemented.new("format_attribution")
|
|
614
|
+
end
|
|
615
|
+
|
|
616
|
+
def format_citation(published_metadata:, citation_style:)
|
|
617
|
+
raise Unimplemented.new("format_citation")
|
|
618
|
+
end
|
|
619
|
+
|
|
620
|
+
def parse_prediction_window(time_inputs:, window_inputs:, step:, local_time_profile:)
|
|
621
|
+
if time_inputs.member_id == "Release.heights_at"
|
|
622
|
+
times = time_inputs.times
|
|
623
|
+
raise InvalidArgumentError, "times must be an Array of Time" unless times.is_a?(Array)
|
|
624
|
+
instants = times.map { |time| Predict.instant(time) }
|
|
625
|
+
return CanonicalTypes::PredictionWindow.new(start: nil, stop: nil, step: nil, instants: instants)
|
|
626
|
+
end
|
|
627
|
+
cadence = %w[Release.heights Release.currents].include?(window_inputs.member_id) ? step : nil
|
|
628
|
+
first, last = Predict.window(window_inputs.start, window_inputs.stop, cadence)
|
|
629
|
+
if !cadence.nil? || %w[Release.heights Release.currents].include?(window_inputs.member_id)
|
|
630
|
+
raise InvalidArgumentError, "step_s must be a positive integer" unless cadence.is_a?(Integer) && cadence > 0
|
|
631
|
+
end
|
|
632
|
+
CanonicalTypes::PredictionWindow.new(start: first, stop: last, step: cadence, instants: nil)
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
def select_prediction_model(station_request:, release_view:, selection_options:, reader_version:)
|
|
636
|
+
raise Unimplemented.new("select_prediction_model")
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
def evaluate_astronomy(selected_prediction_model:, utc_instant:)
|
|
640
|
+
year = Predict.utc(utc_instant).year
|
|
641
|
+
total = selected_prediction_model.native_context.total
|
|
642
|
+
origin, terms = total.daily? ? total.day_data(utc_instant, year) : total.year_data(year)
|
|
643
|
+
CanonicalTypes::AstronomicalTerms.new(utc_year: year, constituent_terms: terms.map { |term| term.dup.freeze }.freeze, epoch_hours: origin / 3600.0)
|
|
644
|
+
end
|
|
645
|
+
|
|
646
|
+
def evaluate_harmonic_height(selected_prediction_model:, prediction_instants:, requested_datum:)
|
|
647
|
+
context = selected_prediction_model.native_context
|
|
648
|
+
unless context && selected_prediction_model.selection_context.equal?(context) && !selected_prediction_model.prepared_datum.equal?(CanonicalTypes::ABSENT) && (selected_prediction_model.prepared_datum || "mean_level") == requested_datum
|
|
649
|
+
raise Unimplemented.new("evaluate_harmonic_height mismatched or missing prepared datum/Context binding")
|
|
650
|
+
end
|
|
651
|
+
prediction_instants.map do |instant|
|
|
652
|
+
evaluate_astronomy(selected_prediction_model: selected_prediction_model, utc_instant: instant)
|
|
653
|
+
selected_prediction_model.native_context.total.value(instant)
|
|
654
|
+
end
|
|
655
|
+
end
|
|
656
|
+
|
|
657
|
+
def find_tide_events(selected_prediction_model:, prediction_window:)
|
|
658
|
+
raise Unimplemented.new("find_tide_events")
|
|
659
|
+
end
|
|
660
|
+
|
|
661
|
+
def evaluate_direct_current(selected_prediction_model:, prediction_window:, current_request:, current_operation:)
|
|
662
|
+
raise Unimplemented.new("evaluate_direct_current")
|
|
663
|
+
end
|
|
664
|
+
|
|
665
|
+
def evaluate_tide_offset(own_offset:, reference_path:, prediction_window:, tide_request:, reader_version:)
|
|
666
|
+
raise Unimplemented.new("evaluate_tide_offset")
|
|
667
|
+
end
|
|
668
|
+
|
|
669
|
+
def fold_equal_tide_offset(own_offset:, reference_model:, prediction_instants:, requested_datum:)
|
|
670
|
+
raise Unimplemented.new("fold_equal_tide_offset")
|
|
671
|
+
end
|
|
672
|
+
|
|
673
|
+
def evaluate_current_offset(own_current_offsets:, reference_path:, prediction_window:, current_request:, reader_version:)
|
|
674
|
+
raise Unimplemented.new("evaluate_current_offset")
|
|
675
|
+
end
|
|
676
|
+
|
|
677
|
+
def dispatch_auxiliary_result(auxiliary_kind:, auxiliary_operation:, source_values:, result_context:, local_time_profile:, result_values:, utc_result:, selection_options:, reader_version:, auxiliary_member_id:)
|
|
678
|
+
raise Unimplemented.new("dispatch_auxiliary_result")
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
def retain_raw_source_record(source_record:, native_profile:)
|
|
682
|
+
Util.deep_freeze(source_record)
|
|
683
|
+
end
|
|
684
|
+
|
|
685
|
+
def check_station_origin(station:, release_origin:)
|
|
686
|
+
raise Unimplemented.new("check_station_origin requires genuine producing Release") unless release_origin.is_a?(Release)
|
|
687
|
+
release_origin.__send__(:own_station!, station, "station")
|
|
688
|
+
station
|
|
689
|
+
end
|
|
690
|
+
|
|
691
|
+
def manage_cache_lock(lock_request:, lock_state:, clock:)
|
|
692
|
+
raise Unimplemented.new("manage_cache_lock")
|
|
693
|
+
end
|
|
694
|
+
|
|
695
|
+
def request_http_resource(http_request:, transport_options:)
|
|
696
|
+
raise Unimplemented.new("request_http_resource")
|
|
697
|
+
end
|
|
698
|
+
|
|
699
|
+
def count_release_statistics(release_view:)
|
|
700
|
+
raise Unimplemented.new("count_release_statistics")
|
|
701
|
+
end
|
|
702
|
+
|
|
703
|
+
def order_constant_sets(station_sets:, original_recommendation:, commercial_only:, include_no_constants:)
|
|
704
|
+
raise Unimplemented.new("order_constant_sets")
|
|
705
|
+
end
|
|
706
|
+
|
|
707
|
+
def read_auxiliary_model_value(auxiliary_operation:, source_values:, selection_options:, reader_version:, auxiliary_member_id:)
|
|
708
|
+
raise Unimplemented.new("read_auxiliary_model_value")
|
|
709
|
+
end
|
|
710
|
+
|
|
711
|
+
def construct_prediction_result(result_values:, result_context:)
|
|
712
|
+
raise Unimplemented.new("construct_prediction_result")
|
|
713
|
+
end
|
|
714
|
+
|
|
715
|
+
def convert_result_to_local_time(utc_result:, local_time_profile:)
|
|
716
|
+
raise Unimplemented.new("convert_result_to_local_time")
|
|
717
|
+
end
|
|
718
|
+
|
|
719
|
+
def find_unrounded_tide_events(selected_prediction_model:, prediction_window:)
|
|
720
|
+
Predict.__send__(:unrounded_events, selected_prediction_model.native_context.total, prediction_window.start, prediction_window.stop).each_with_index.map do |(root, kind, value), order|
|
|
721
|
+
CanonicalTypes::UnroundedTideEvent.new(root_seconds: root, event_type: kind, height_m: value, reference_order: order)
|
|
722
|
+
end
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
def find_unrounded_current_events(selected_prediction_model:, prediction_window:, current_request:)
|
|
726
|
+
context = selected_prediction_model.native_context
|
|
727
|
+
bound = selected_prediction_model.prepared_current_request
|
|
728
|
+
unless context && selected_prediction_model.selection_context.equal?(context) && (bound.is_a?(CanonicalTypes::ArgsReleaseCurrents) || bound.is_a?(CanonicalTypes::ArgsReleaseCurrentEvents)) && bound.class == current_request.class && %i[member_id station start stop bin_number set_id].all? { |field| bound.public_send(field) == current_request.public_send(field) }
|
|
729
|
+
raise Unimplemented.new("find_unrounded_current_events mismatched or missing prepared current request/Context binding")
|
|
730
|
+
end
|
|
731
|
+
Predict.__send__(:unrounded_current_events, selected_prediction_model.native_context, prediction_window.start, prediction_window.stop).each_with_index.map do |(root, kind, value, direction), order|
|
|
732
|
+
CanonicalTypes::UnroundedCurrentEvent.new(root_seconds: root, event_type: kind, velocity_m_s: value, direction_deg: direction, reference_order: order)
|
|
733
|
+
end
|
|
734
|
+
end
|
|
735
|
+
|
|
736
|
+
def acquire_checksum_sidecar(acquisition_descriptor:, effective_options:)
|
|
737
|
+
raise Unimplemented.new("acquire_checksum_sidecar")
|
|
738
|
+
end
|
|
739
|
+
|
|
740
|
+
def client_option_keywords(arguments, defaults = nil)
|
|
741
|
+
%i[release file cache_dir offline mode base_url timeout proxy ca_file user_agent on_network_error auto_update update_interval logger verify_on_open commercial_only commercial_basis historical_offsets_policy].each_with_object({}) do |name, options|
|
|
742
|
+
value = arguments.public_send(name)
|
|
743
|
+
value = defaults.public_send(name) if value.equal?(CanonicalTypes::ABSENT) && defaults
|
|
744
|
+
options[name] = value unless value.equal?(CanonicalTypes::ABSENT)
|
|
745
|
+
end
|
|
746
|
+
end
|
|
747
|
+
|
|
748
|
+
def argument_value(arguments, name, default)
|
|
749
|
+
return default unless arguments.respond_to?(name)
|
|
750
|
+
value = arguments.public_send(name)
|
|
751
|
+
value.equal?(CanonicalTypes::ABSENT) || value.nil? && name == :filters ? default : value
|
|
752
|
+
end
|
|
753
|
+
|
|
754
|
+
end
|
|
755
|
+
private_constant :Canonical
|
|
756
|
+
end
|