Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,15 @@ with ReportnetClient(base_url="https://api.reportnet.europa.eu", token="<jwt>")
import asyncio
from reportnet_api import AsyncReportnetClient


async def main() -> None:
async with AsyncReportnetClient(
base_url="https://api.reportnet.europa.eu", token="<jwt>"
) as client:
schema = await client.dataset_schema.find_data_schema_by_dataset_id(dataset_id=123)
await client.datasets.import_file_data(dataset_id=123, file="local/path.csv") # WRITES data


asyncio.run(main())
```

Expand All @@ -148,15 +150,19 @@ Upload and download are path-based and streaming, not in-memory bytes:
```python
client.datasets.import_file_data(dataset_id=123, file="local/path.csv") # WRITES data
client.dataset_snapshot.download_historic_releases_csv(
dataflow_id=1, dataset_id=123, file_name="releases.csv", dest="local/out.csv",
dataflow_id=1,
dataset_id=123,
file_name="releases.csv",
dest="local/out.csv",
)

# Full dataflow schema export ZIP (.schema/.qcrules/.unique/.integrity/
# .extintegrations per dataset, plus datasetSchemaNames.names/
# datasetSchemaIds.ids) — same format the Reportnet UI's schema export
# produces. Requires DATAFLOW_CUSTODIAN or DATAFLOW_STEWARD on the dataflow.
client.dataset_schema.export_dataflow_schemas_zip(
dataflow_id=4321, dest="local/dataflow_4321_schemas.zip",
dataflow_id=4321,
dest="local/dataflow_4321_schemas.zip",
)
```

Expand All @@ -176,7 +182,7 @@ try:
client.datasets.check_import_process(dataset_id=999)
except NotFoundError as e:
print(e.status_code, e.response_body)
print(e) # includes the server's JSON `message` (first 200 chars)
print(e) # includes the server's JSON `message` (first 200 chars)
print(e.explain()) # plain-language cause and what to try
```

Expand Down
2 changes: 1 addition & 1 deletion docs/credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Custodian or Steward role, use a login (Bearer) token.**
from reportnet_api.easy import connect_interactive, check_access

client = connect_interactive()
check_access(client) # read-only; add a dataflow id to test access to it
check_access(client) # read-only; add a dataflow id to test access to it
```

## Common errors
Expand Down
3 changes: 2 additions & 1 deletion docs/fme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import fme
import fmeobjects
from reportnet_api import easy


class FeatureProcessor(object):
def __init__(self):
self.rows = []
Expand All @@ -49,7 +50,7 @@ class FeatureProcessor(object):
)
finally:
client.close()
for row in rows: # every value is text, empty cells are ''
for row in rows: # every value is text, empty cells are ''
out = fmeobjects.FMEFeature()
for name, value in row.items():
out.setAttribute(name, value)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ select = [
# ANN is left out on purpose: mypy strict already enforces annotations.
ignore = [
"PLR0913", # resource methods mirror the endpoint's parameters
"PLR0917", # same; making them keyword-only would break positional callers
"PLC0415", # pandas is imported lazily so that it stays optional
"FBT001", # boolean parameters are public API; changing them is a breaking change
"FBT002", # same
Expand Down
4 changes: 2 additions & 2 deletions tests/test_representative.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ async def run() -> None:
def test_create_lead_reporter_is_keyword_only() -> None:
with ReportnetClient(base_url=BASE_URL, token="t") as client:
with pytest.raises(TypeError):
client.representative.create_lead_reporter(77, 5, "a@example.org") # type: ignore[misc]
client.representative.create_lead_reporter(77, 5, "a@example.org") # type: ignore[call-arg]

async def run() -> None:
async with AsyncReportnetClient(base_url=BASE_URL, token="t") as client:
with pytest.raises(TypeError):
await client.representative.create_lead_reporter(77, 5, "a@example.org") # type: ignore[misc]
await client.representative.create_lead_reporter(77, 5, "a@example.org") # type: ignore[call-arg]

asyncio.run(run())

Expand Down
Loading