Skip to content

Commit

Permalink
fix cdl config file not available
Browse files Browse the repository at this point in the history
  • Loading branch information
franckalbinet committed Sep 26, 2023
1 parent 475cc4c commit aae8387
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 216 deletions.
11 changes: 4 additions & 7 deletions marisco/metadata.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/metadata.ipynb.

# %% auto 0
__all__ = ['GLOB_ATTRS_TPL', 'GlobAttrsFeeder', 'BboxCB', 'DepthRangeCB', 'TimeRangeCB', 'ZoteroCB', 'KeyValuePairCB',
'ZoteroItem']
__all__ = ['GlobAttrsFeeder', 'BboxCB', 'DepthRangeCB', 'TimeRangeCB', 'ZoteroCB', 'KeyValuePairCB', 'ZoteroItem']

# %% ../nbs/api/metadata.ipynb 2
import pandas as pd
Expand All @@ -11,18 +10,16 @@

from .utils import (read_toml, get_bbox,
Callback, run_cbs)
from .configs import BASE_PATH, get_cfgs
from .configs import BASE_PATH, get_cfgs, CONFIGS_CDL

from cftime import num2date
from pyzotero import zotero
import json

# %% ../nbs/api/metadata.ipynb 3
GLOB_ATTRS_TPL = read_toml(BASE_PATH / 'cdl.toml')['global_attrs']

# %% ../nbs/api/metadata.ipynb 4
class GlobAttrsFeeder:
def __init__(self, dfs, cbs=None, attrs=GLOB_ATTRS_TPL, logs=[]): fc.store_attr()
def __init__(self, dfs, cbs=None, attrs=CONFIGS_CDL['global_attrs'], logs=[]):
fc.store_attr()

def callback(self):
run_cbs(self.cbs, self)
Expand Down
4 changes: 2 additions & 2 deletions marisco/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_bbox(df,
arr.append((row[x], row[y]))
return MultiPoint(arr).envelope

# %% ../nbs/api/utils.ipynb 22
# %% ../nbs/api/utils.ipynb 20
def download_files_in_folder(owner, repo, src_dir, dest_dir):
# Make a GET request to the GitHub API to get the contents of the folder
url = f"https://api.github.com/repos/{owner}/{repo}/contents/{src_dir}"
Expand Down Expand Up @@ -106,7 +106,7 @@ def download_file(owner, repo, src_dir, dest_dir, fname):
else:
print(f"Error: {response.status_code}")

# %% ../nbs/api/utils.ipynb 24
# %% ../nbs/api/utils.ipynb 22
def match_worms(
name:str # Name of species to look up in WoRMS
):
Expand Down
8 changes: 4 additions & 4 deletions nbs/api/metadata.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"\n",
"from marisco.utils import (read_toml, get_bbox, \n",
" Callback, run_cbs)\n",
"from marisco.configs import BASE_PATH, get_cfgs\n",
"from marisco.configs import BASE_PATH, get_cfgs, CONFIGS_CDL\n",
"\n",
"from cftime import num2date\n",
"from pyzotero import zotero\n",
Expand All @@ -48,8 +48,7 @@
"metadata": {},
"outputs": [],
"source": [
"#| export\n",
"GLOB_ATTRS_TPL = read_toml(BASE_PATH / 'cdl.toml')['global_attrs']"
"# GLOB_ATTRS_TPL = read_toml(BASE_PATH / 'cdl.toml')['global_attrs']"
]
},
{
Expand All @@ -61,7 +60,8 @@
"source": [
"#| export\n",
"class GlobAttrsFeeder:\n",
" def __init__(self, dfs, cbs=None, attrs=GLOB_ATTRS_TPL, logs=[]): fc.store_attr()\n",
" def __init__(self, dfs, cbs=None, attrs=CONFIGS_CDL['global_attrs'], logs=[]): \n",
" fc.store_attr()\n",
" \n",
" def callback(self):\n",
" run_cbs(self.cbs, self)\n",
Expand Down
27 changes: 0 additions & 27 deletions nbs/api/utils.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -277,33 +277,6 @@
"bbox.wkt"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "7c2eef73",
"metadata": {},
"source": [
"## Notebooks"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b0a463a1",
"metadata": {},
"outputs": [],
"source": [
"#| hide\n",
"# TO BE REMOVED: NOT USED ANYMORE - REFACTORED\n",
"def parametrize(notebook:str, # Notebook path\n",
" ):\n",
" \"Add `parameters` notebook cell tag when seeing `#| params` special character\"\n",
" nb = nbformat.read(notebook, as_version=4)\n",
" cell = [c for c in nb.cells if '#|params' in c.source.replace(' ', '')][0]\n",
" cell.metadata = {'tags': ['parameters']}\n",
" nbformat.write(nb, notebook)"
]
},
{
"attachments": {},
"cell_type": "markdown",
Expand Down
Loading

0 comments on commit aae8387

Please sign in to comment.