home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1422460071

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1422460071 I_kwDOAMm_X85UyQSn 7211 Incorrect handle to Dagster frozenlists in Dataset object 64480652 closed 0     4 2022-10-25T13:23:09Z 2022-10-31T12:39:05Z 2022-10-31T12:39:05Z NONE      

What happened?

Dataset object could not be fetched with Dataset[variables] when variables is a frozenlist. There is some source code that can replicate this behaviour.

What did you expect to happen?

Dataset[variables] returning a new fetched dataset. It returns a key error.

Minimal Complete Verifiable Example

```Python

%%

from dagster import Output, asset, Field, build_op_context import numpy as np import pandas as pd import xarray as xr

def retrieve_dataset(date, fct_step, lats, lons, runtime, source, variables):

dt = str(date)[0:10].replace("-", "")
year = dt[0:4]
prev_n = "{}".format(fct_step).zfill(3)

lat_toplot = np.arange(
    min(lats), max(lats), 0.25
)  # last number is exclusive
lon_toplot = (
    np.arange(min(lons), max(lons), 0.25) % 360
)  # last number is exclusive

gfs_model = "ds084.1"
URL = f"https://rda.ucar.edu/thredds/dodsC/files/g/{gfs_model}/{year}/{dt}/gfs.0p25.{dt}{runtime}.f{prev_n}.grib2"

dataset = xr.open_dataset(URL, cache=True, engine="netcdf4")[variables]

# Select required data via xarray
dataset = dataset.sel(lon=lon_toplot, lat=lat_toplot)[variables]

return dataset

@asset( description="GFS dataset fetched for NOAA Forecast data from NOAA NOMADS server.", config_schema=dict( variables=Field(list), ), output_required=True, ) def ncar_dataset(context):

date = "2022-02-01"
fct_step = 0
lats = [-4.0, -2.75]
lons = [-41.5, -40.25]
runtime = "00"
# variables = list(context.op_config["variables"])  <--- This way it runs
variables = context.op_config["variables"]
source = "model-gfs-003"

dataset = retrieve_dataset(
    date, fct_step, lats, lons, runtime, source, variables
)

return Output(dataset)

test_variable = "u-component_of_wind_height_above_ground"

with build_op_context( op_config={ "variables": [test_variable], } ) as context:

dataset_ast = ncar_dataset(context)

dataset = dataset_ast.value ```

MVCE confirmation

  • [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • [ ] Complete example — the example is self-contained, including all data and the text of any traceback.
  • [X] Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • [X] New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

Python I raises KeyError

Anything else we need to know?

No response

Environment

Python 3.10.4 pandas==1.5.0 xarray==0.19.0 netCDF4==1.5.7 dagster dagit
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7211/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 4 rows from issue in issue_comments
Powered by Datasette · Queries took 0.663ms · About: xarray-datasette