Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/0.7' into 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
hartym committed Nov 16, 2024
2 parents f6f549b + 04b973a commit 1d01938
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 207 deletions.
8 changes: 4 additions & 4 deletions docs/apps/http_client/examples/full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ http_client:
# Customize the httpx transport layer (optional)
transport:
# This is the default, only set if you want to use a custom transport. Most users don't need to set this.
"@type": "httpx:AsyncHTTPTransport"
type: httpx.AsyncHTTPTransport

# Cache configuration (optional, enabled by default)
cache:
Expand All @@ -15,7 +15,7 @@ http_client:
# Override the cache controller definition (optional)
controller:
# This is the default, only set if you want to use a custom controller.
"@type": "hishel:Controller"
type: hishel.Controller

# You can configure anything the hishel cache controller would accept as a keyword argument.
# See https://hishel.com/advanced/controllers/ for more information.
Expand All @@ -36,7 +36,7 @@ http_client:
# layer extending the base http client features with caching.
transport:
# This is the default, only set if you want to use a custom cache transport.
"@type": "hishel:AsyncCacheTransport"
type: hishel.AsyncCacheTransport

# If your hishel compatible transport class take more kwargs, you can pass more stuff here.
# See https://hishel.com/userguide/#clients-and-transports
Expand All @@ -45,7 +45,7 @@ http_client:
# Please note that we plan to allow to share other harp storages here in the future.
storage:
# This is the default, only set if you want to use a custom cache storage.
"@type": "hishel:AsyncFileStorage"
type: hishel.AsyncFileStorage

# If your hishel compatible storage class take more kwargs, you can pass more stuff here.
# See https://hishel.com/advanced/storages/
2 changes: 1 addition & 1 deletion docs/apps/http_client/examples/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ http_client:
transport:
# You can customize the default transport implementation. The values shown are the
# defaults, and you only need to set them if you want to provide different values.
"@type": "httpx:AsyncHTTPTransport"
type: httpx.AsyncHTTPTransport
retries: 0
verify: true
http1: true
Expand Down
3 changes: 2 additions & 1 deletion docs/changelogs/unreleased.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Changed
Fixed
:::::

* Cache: on retrieval/decoding failure, consider no cache is available.
* DX: Add the ability to use --set x=y or --set x y (both equivalent) to all commands (@masterivanic, #590)
* UI: Correctly display header values containing a semicolon character (#577, @ArthurD1)
* UI: Fixed the topology UI where changing the state of a remote would cause the page to crash (#578, @ArthurD1).
* Cache: on retrieval/decoding failure, consider no cache is available.
* UI: On transactions page, tpdex filter now includes both sides of the selected range (#391, @ArthurD1)
6 changes: 5 additions & 1 deletion harp/config/configurables/service.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from keyword import iskeyword
from typing import Literal, Optional

from pydantic import ConfigDict, Field, model_serializer, model_validator
Expand Down Expand Up @@ -32,7 +33,10 @@ def __validate(cls, values):
arguments = values.get("arguments", {})
for k in list(values.keys()):
if k not in cls.model_fields:
arguments[k] = values.pop(k)
if str.isidentifier(k) and not iskeyword(k):
arguments[k] = values.pop(k)
else:
raise ValueError(f"Invalid field name: {k} for {cls.__name__}")
if len(arguments):
return {**values, "arguments": arguments}
return values
Expand Down
10 changes: 4 additions & 6 deletions harp/config/tests/__snapshots__/test_all_examples.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
http_client:
cache:
controller:
'@type': hishel:Controller
allow_heuristics: true
allow_stale: true
cacheable_methods:
Expand All @@ -149,13 +148,12 @@
- 200
- 301
- 308
type: hishel.Controller
storage:
'@type': hishel:AsyncFileStorage
transport:
'@type': hishel:AsyncCacheTransport
type: hishel.AsyncFileStorage
timeout: 10.0
transport:
'@type': httpx:AsyncHTTPTransport
type: httpx.AsyncHTTPTransport
proxy: {}
rules: {}
storage: {}
Expand All @@ -180,10 +178,10 @@
http_client:
timeout: 10.0
transport:
'@type': httpx:AsyncHTTPTransport
http1: true
http2: false
retries: 0
type: httpx.AsyncHTTPTransport
verify: true
proxy: {}
rules: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,28 @@ export function FiltersSidebar({ filters }: FiltersSidebarProps) {
label: rating.label,
className: rating.className,
}))
const markValueToThreshold = new Map([...tpdexScale].map((rating, index) => [index * 10, rating.threshold]))
const maxKey = Math.max(...Array.from(markValueToThreshold.keys()))
const minKey = Math.min(...Array.from(markValueToThreshold.keys()))
markValueToThreshold.set(maxKey, undefined)
markValueToThreshold.set(minKey, undefined)

const thresholdToMarkValue = new Map<number, number>()
markValueToThreshold.forEach((value, key) => {
const markValueToThresholdForMin = new Map([...tpdexScale].map((rating, index) => [index * 10, rating.threshold]))
const markValueToThresholdForMax = new Map(
[...tpdexScale].map((rating, index) => [(index + 1) * 10, rating.threshold ? rating.threshold - 1 : undefined]),
)
const maxKey = Math.max(...Array.from(markValueToThresholdForMin.keys()))
const minKey = Math.min(...Array.from(markValueToThresholdForMin.keys()))

// remove the last mark for min and the first mark for max
markValueToThresholdForMin.set(maxKey, undefined)
markValueToThresholdForMax.set(minKey, undefined)

const thresholdToMarkValueforMin = new Map<number, number>()
markValueToThresholdForMin.forEach((value, key) => {
if (value != undefined) {
thresholdToMarkValueforMin.set(value, key)
}
})

const thresholdToMarkValueforMax = new Map<number, number>()
markValueToThresholdForMax.forEach((value, key) => {
if (value != undefined) {
thresholdToMarkValue.set(value, key)
thresholdToMarkValueforMax.set(value, key)
}
})

Expand All @@ -57,8 +69,8 @@ export function FiltersSidebar({ filters }: FiltersSidebarProps) {
}

const setTpdexValues = (value: MinMaxFilter | undefined) => {
const maxValue = markValueToThreshold.get(value?.min ?? -1)
const minValue = markValueToThreshold.get(value?.max ?? -1)
const maxValue = markValueToThresholdForMax.get(value?.min ?? -1)
const minValue = markValueToThresholdForMin.get(value?.max ?? -1)

if (minValue != null) {
searchParams.set("tpdexmin", minValue.toString())
Expand Down Expand Up @@ -138,8 +150,8 @@ export function FiltersSidebar({ filters }: FiltersSidebarProps) {
title="Performances Index"
name="performanceIndex"
values={{
min: thresholdToMarkValue.get((filters["tpdex"] as MinMaxFilter)?.max ?? 0),
max: thresholdToMarkValue.get((filters["tpdex"] as MinMaxFilter)?.min ?? 100),
min: thresholdToMarkValueforMax.get((filters["tpdex"] as MinMaxFilter)?.max ?? 0),
max: thresholdToMarkValueforMin.get((filters["tpdex"] as MinMaxFilter)?.min ?? 100),
}}
setValues={setTpdexValues}
marks={marks}
Expand Down
Loading

0 comments on commit 1d01938

Please sign in to comment.