I hope this is the right channel to ask for genera...
# ask-community
p
I hope this is the right channel to ask for general help. I was curious why this happens:
Copy code
lat_size = Parameter("Latitude Size (e.g 1 for a 1x1 degree grid)", default=1.0)
lon_size = Parameter("Longitude Size (e.g 1 for a 1x1 degree grid)", default=1.0)
lats = np.arange(-90, 90, lat_size)
lons = np.arange(-180, 180, lon_size)
but then:
Copy code
$ prefect register --project tutorial -p simulation_workflows/workflows
Collecting flows...
osgeo is not installed, conversion to Geo formats like Geotiff (fesom2GeoFormat) will not work.
Error loading 'simulation_workflows/workflows/fesom_2d_variable.py':
  Traceback (most recent call last):
    File "/Users/pgierz/.local/opt/miniconda3/envs/scicomp_esm_sim_prefect_workflows/lib/python3.9/site-packages/prefect/cli/build_register.py", line 134, in load_flows_from_script
    namespace = runpy.run_path(abs_path, run_name="<flow>")
    File "/Users/pgierz/.local/opt/miniconda3/envs/scicomp_esm_sim_prefect_workflows/lib/python3.9/runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
    File "/Users/pgierz/.local/opt/miniconda3/envs/scicomp_esm_sim_prefect_workflows/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
    File "/Users/pgierz/.local/opt/miniconda3/envs/scicomp_esm_sim_prefect_workflows/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
    File "/Users/pgierz/Documents/SciComp/Projects/Workflows/simulation_workflows/simulation_workflows/workflows/fesom_2d_variable.py", line 27, in <module>
    lons = np.arange(-180, 180, lon_size.value)
  AttributeError: 'Parameter' object has no attribute 'value'
Is the stupid solution just to make a mini task instead of directly using numpy?
a
exactly, you would need to move this block:
Copy code
lats = np.arange(-90, 90, lat_size)
lons = np.arange(-180, 180, lon_size)
into individual task(s).
In the Flow constructor, you can’t call any “normal” Python code, only Prefect tasks.
p
and tasks must be functions, right? I cannot make a class, and then make one of it’s methods a task?
a
you could have a class and call it within a function right?
apart from that we have the imperative API, but the functional API is recommended
p
ok, thanks! I’ll play around with it a bit 🙂