Comments (8)
Sigh. Frustratingly unlisting a package doesn't seem to stop nuget from resolving it.
I'll push a 5.0.2 with the package split undone, then work to find a resolution
from fsharp.data.
I see, thank you. I will unlist the package and get this fixed
from fsharp.data.
@vars-ecco Do you have a minimal repro script please, with information on how you run it? Thank you
from fsharp.data.
@dsyme please see here https://github.com/vars-ecco/ErrorSample
from fsharp.data.
same problem here; this is the code (non-minimal):
#r "nuget: FSharp.Data"
#r "System.Xml.Linq.dll"
open System
open System.Globalization
open FSharp.Data
[<Literal>]
let path = __SOURCE_DIRECTORY__ + "/ALL.xhb"
type ExchangeRateApiGbp =
JsonProvider<"https://open.er-api.com/v6/latest/GBP">
type ExchangeRateApiUsd =
JsonProvider<"https://open.er-api.com/v6/latest/USD">
let gbpToEur =
ExchangeRateApiGbp.GetSample().Rates.Eur
let usdToEur =
ExchangeRateApiUsd.GetSample().Rates.Eur
type YahooFinanceMsft =
JsonProvider<"https://query1.finance.yahoo.com/v8/finance/chart/MSFT">
let currentMsftStockPrice =
YahooFinanceMsft.GetSample().Chart.Result[0].Meta.RegularMarketPrice
let currencySymbol =
[ "EUR", "€"
"USD", "$"
"GBP", "£"
"MSF", "S" ]
|> Map.ofList
type HomeBank = XmlProvider<path>
try
let data = HomeBank.GetSample()
let accounts =
data.Accounts
|> Array.map (fun a -> a.Key, a)
|> Map.ofArray
let currencies =
data.Curs
|> Array.map (fun a -> a.Key, a)
|> Map.ofArray
let zpn =
Environment.GetEnvironmentVariable("ZOOPLA_PROPERTY_NUMBER")
let currentPropertyEstimateGbp =
Http.RequestString($"https://www.zoopla.co.uk/property/uprn/{zpn}/", headers = [ "user-agent", "curl/7.84.0" ])
|> HtmlDocument.Parse
|> HtmlDocument.descendants false (fun n -> n.HasId("property-estimate"))
|> Seq.exactlyOne
|> HtmlNode.descendants false (fun n -> n.HasAttribute("data-testid", "estimate-blurred"))
|> Seq.exactlyOne
|> HtmlNode.innerText
|> (fun s -> s.Replace("£", "").Replace(",", ""))
|> Decimal.Parse
// Put all accounts in a summary
let allAccountSummaries =
data.Opes
|> Array.groupBy (fun o -> o.Account)
|> Array.map (fun (a, o) -> accounts[a], o)
|> Array.map (fun (a, o) -> a.Name, (o |> Array.sumBy (fun oi -> oi.Amount)) + a.Initial, currencies[a.Curr].Iso)
// Put all (add property estimate) and convert currency as main label (EUR net worth)
let netWorth =
allAccountSummaries
|> Array.sumBy (fun r -> match r with
| "Fidelity (vested)" , amount, _ -> amount * currentMsftStockPrice * usdToEur
| "Fidelity (unvested)", _ , _ -> 0m
| _ , amount, "EUR" -> amount
| _ , amount, "GBP" -> amount * gbpToEur
| _ -> failwith "Unsupported currency")
|> (fun x -> x + (currentPropertyEstimateGbp * gbpToEur))
let maxAccountNameLength =
allAccountSummaries
|> Array.map (fun (name, _, _) -> name.Length)
|> Array.max
let formatName (name : string) =
name.Replace(" (EUR)", "").Replace(" (GBP)", "").PadRight(maxAccountNameLength)
let formatAmount (amount : decimal) currency =
let defaultPadding = 13
let format (amount : decimal) (locale : string) padding =
String.Format(CultureInfo(locale), "{0:c}", amount).PadRight(padding)
match currency with
| "USD" -> $"""{format amount "en-US" defaultPadding} ({format (amount * usdToEur) "it-IT" 0})"""
| "EUR" -> $"""{format amount "it-IT" defaultPadding}"""
| "GBP" -> $"""{format amount "en-GB" defaultPadding} ({format (amount * gbpToEur) "it-IT" 0})"""
| "MSF" -> $"""{($"{amount:f2} shares".PadRight(defaultPadding))} ({format (amount * currentMsftStockPrice * usdToEur) "it-IT" 0})"""
| _ -> failwith "Unsupported currency"
let tooltip =
allAccountSummaries
|> Array.sortByDescending (fun (_, amount, _) -> amount)
|> Array.map (fun (name, amount, currency) -> $"""{formatName name} {formatAmount amount currency}""")
|> String.concat "\n"
$"""
<txt> €{netWorth:n0} </txt>
<txtclick>homebank</txtclick>
<tool><tt>{tooltip}</tt></tool>
"""
|> printfn "%s"
with ex ->
$"""
<txt> Error </txt>
<txtclick>zenity --error --no-wrap --text="{ex.StackTrace}"</txtclick>
<tool>{ex.Message}</tool>
"""
|> printfn "%s"
that works on another person's machine.
if I pin the version (even to the latest #r "nuget: FSharp.Data, 4.2.10"
) it works, if I omit it, I get the same error as above.
pinning is a good workaround for me, sharing the details to help resolve.
thanks
from fsharp.data.
@UnoSD @vars-ecco I have fixed the problem (via a workaround) and 6.0.1-beta001 is published.
Could I ask you a favour to try this version with your scripts on your machines? I've tried yours @UnoSD and it Works On My Machine ™️
Thanks
from fsharp.data.
@dsyme yep, works well on mine, too. I think the latest (then unlisted, I presume) version was downloaded and cached, hence why it wasn't working and I had to pin. thanks.
from fsharp.data.
@dsyme works on my machine as well. thanks!
from fsharp.data.
Related Issues (20)
- Support DateOnly and TimeOnly types HOT 2
- FSharp.Data.Core.Tests.CSharp.csproj: [NU1504] Duplicate 'PackageReference' items found. HOT 2
- s HOT 1
- JsonProvider - writable properties? HOT 1
- When closing VS 2022, the FSharp.Data.DesignTime stays on lock that prevents closing the editor. HOT 1
- Why are the core features (`CommonRuntime` folder) implemented in the Http project? HOT 6
- Question: an F# type provider backed by ML.NET for AI/learning HOT 1
- A way forward with the JsonProvider HOT 17
- Requesting a new beta package published to nuget.org HOT 3
- FSharp.Data.Runtime.Utilities is not published HOT 2
- Preserving linefeed style HOT 3
- A new FSharp.Data.JsonSaveOptions value needed HOT 3
- XmlProvider generates types based on name attribute in XSD schema rather than the type attribute HOT 5
- support empty space separator HOT 1
- update pictures in docs with #r nuget reference (no .dll ref)
- Update FSharp.Core from 5 to 6 or 7, to get less memory usage and better performance HOT 4
- System.Text.Json for JsonProvider? HOT 1
- Memory Limitations in XmlProvider HOT 10
- FS3033: Multiple definition of element error.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fsharp.data.