Skip to content

Commit 56bf54a

Browse files
authored
Merge pull request #351 from digital-land/revert-branch
Revert branch
2 parents 47fc2f9 + 42d6a03 commit 56bf54a

File tree

5 files changed

+0
-171
lines changed

5 files changed

+0
-171
lines changed

digital_land/cli.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
column_field_dir,
4545
converted_resource_dir,
4646
output_log_dir,
47-
provision_summary_dir,
4847
)
4948

5049

@@ -228,7 +227,6 @@ def dataset_dump_flattened_cmd(ctx, input_path, output_path):
228227
@dataset_resource_dir
229228
@converted_resource_dir
230229
@organisation_path
231-
@provision_summary_dir
232230
@collection_dir
233231
@operational_issue_dir
234232
@output_log_dir
@@ -252,7 +250,6 @@ def pipeline_command(
252250
config_path,
253251
resource,
254252
output_log_dir,
255-
provision_summary_dir,
256253
):
257254
dataset = ctx.obj["DATASET"]
258255
pipeline = ctx.obj["PIPELINE"]
@@ -282,7 +279,6 @@ def pipeline_command(
282279
config_path=config_path,
283280
resource=resource,
284281
output_log_dir=output_log_dir,
285-
provision_summary_dir=provision_summary_dir,
286282
)
287283

288284

digital_land/command_arguments.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,3 @@ def organisation_path(f):
9797
type=click.Path(exists=True),
9898
default="var/cache/organisation.csv",
9999
)(f)
100-
101-
102-
def provision_summary_dir(f):
103-
return click.option(
104-
"--provision-summary-dir",
105-
type=click.Path(exists=True),
106-
default="var/cache/provision-summary.csv",
107-
)(f)

digital_land/commands.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ def pipeline_run(
216216
resource=None,
217217
output_log_dir=None,
218218
converted_path=None,
219-
provision_summary_dir="var/cache/provision_summary.csv",
220219
):
221220
# set up paths
222221
cache_dir = Path(cache_dir)
@@ -331,7 +330,6 @@ def pipeline_run(
331330
issue_log=issue_log,
332331
operational_issue_log=operational_issue_log,
333332
entity_range=[entity_range_min, entity_range_max],
334-
provision_summary_dir=provision_summary_dir,
335333
),
336334
SavePhase(
337335
default_output_path("harmonised", input_path),

digital_land/phase/lookup.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import re
22
import logging
3-
import pandas as pd
43

54
from .phase import Phase
65

@@ -34,15 +33,13 @@ def __init__(
3433
issue_log=None,
3534
operational_issue_log=None,
3635
entity_range=[],
37-
provision_summary_dir=None,
3836
):
3937
self.lookups = lookups
4038
self.redirect_lookups = redirect_lookups
4139
self.issues = issue_log
4240
self.operational_issues = operational_issue_log
4341
self.reverse_lookups = self.build_reverse_lookups()
4442
self.entity_range = entity_range
45-
self.provision_summary_dir = provision_summary_dir
4643

4744
def build_reverse_lookups(self):
4845
reverse_lookups = {}
@@ -166,46 +163,6 @@ def process(self, stream):
166163
row[self.entity_field] = self.redirect_entity(
167164
row[self.entity_field]
168165
)
169-
170-
linked_datasets = ["article-4-direction", "tree-preservation-order"]
171-
if row[self.entity_field]:
172-
for linked_dataset in linked_datasets:
173-
if (
174-
row.get(linked_dataset, "")
175-
or row.get(linked_dataset, "").strip()
176-
):
177-
get_organisations = pd.read_csv(self.provision_summary_dir)
178-
179-
dataset_org = get_organisations[
180-
get_organisations["dataset"] == linked_dataset
181-
]
182-
183-
if (
184-
row.get("organisation", "")
185-
in dataset_org["organisation"].values
186-
):
187-
reference = row.get(linked_dataset, "")
188-
find_entity = self.lookup(
189-
prefix=linked_dataset,
190-
organisation=row.get("organisation", ""),
191-
reference=reference,
192-
)
193-
# raise issue if the found entity is retired in old-entity.csv
194-
if not find_entity or (
195-
str(find_entity) in self.redirect_lookups
196-
and int(
197-
self.redirect_lookups[str(find_entity)].get(
198-
"status", 0
199-
)
200-
)
201-
== 410
202-
):
203-
self.issues.log_issue(
204-
linked_dataset,
205-
"no associated documents found for this area",
206-
reference,
207-
line_number=line_number,
208-
)
209166
yield block
210167

211168

tests/unit/phase/test_lookup.py

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pandas as pd
21
import pytest
32

43
from digital_land.phase.lookup import LookupPhase, EntityLookupPhase, PrintLookupPhase
@@ -20,22 +19,6 @@ def get_input_stream():
2019
]
2120

2221

23-
@pytest.fixture
24-
def get_input_stream_with_linked_field():
25-
return [
26-
{
27-
"row": {
28-
"prefix": "article-4-direction-area",
29-
"reference": "1",
30-
"organisation": "local-authority:ABC",
31-
"article-4-direction": "a4d2",
32-
},
33-
"entry-number": 1,
34-
"line-number": 2,
35-
}
36-
]
37-
38-
3922
@pytest.fixture
4023
def get_lookup():
4124
return {",dataset,1,test": "1"}
@@ -140,103 +123,6 @@ def test_process_empty_prefix(self, get_lookup):
140123

141124
assert output[0]["row"]["entity"] == "10"
142125

143-
def test_no_associated_documents_issue(
144-
self, get_input_stream_with_linked_field, mocker
145-
):
146-
input_stream = get_input_stream_with_linked_field
147-
148-
lookups = {
149-
",article-4-direction,a4d1,local-authorityabc": "1",
150-
",article-4-direction-area,1,local-authorityabc": "2",
151-
}
152-
issues = IssueLog()
153-
154-
phase = LookupPhase(
155-
lookups=lookups,
156-
issue_log=issues,
157-
provision_summary_dir="var/cache/provision-summary/",
158-
)
159-
phase.entity_field = "entity"
160-
mock_df = pd.DataFrame(
161-
{
162-
"organisation": ["local-authority:ABC"],
163-
"dataset": ["article-4-direction"],
164-
}
165-
)
166-
mocker.patch("pandas.read_csv", return_value=mock_df)
167-
output = [block for block in phase.process(input_stream)]
168-
169-
assert output[0]["row"]["entity"] == "2"
170-
assert (
171-
issues.rows[0]["issue-type"]
172-
== "no associated documents found for this area"
173-
)
174-
assert issues.rows[0]["value"] == "a4d2"
175-
176-
def test_no_associated_documents_issue_for_missing_dataset(
177-
self, get_input_stream_with_linked_field, mocker
178-
):
179-
input_stream = get_input_stream_with_linked_field
180-
181-
lookups = {
182-
",article-4-direction,a4d1,local-authorityabc": "1",
183-
",article-4-direction-area,1,local-authorityabc": "2",
184-
}
185-
issues = IssueLog()
186-
187-
phase = LookupPhase(
188-
lookups=lookups,
189-
issue_log=issues,
190-
provision_summary_dir="var/cache/provision-summary/",
191-
)
192-
phase.entity_field = "entity"
193-
mock_df = pd.DataFrame(
194-
{
195-
"organisation": ["local-authority:XYZ", "local-authority:ABC"],
196-
"dataset": ["article-4-direction", "article-4-direction-area"],
197-
}
198-
)
199-
mocker.patch("pandas.read_csv", return_value=mock_df)
200-
output = [block for block in phase.process(input_stream)]
201-
202-
assert output[0]["row"]["entity"] == "2"
203-
assert len(issues.rows) == 0
204-
205-
def test_no_associated_documents_issue_for_retired_entity(
206-
self, get_input_stream_with_linked_field, mocker
207-
):
208-
input_stream = get_input_stream_with_linked_field
209-
210-
lookups = {
211-
",article-4-direction,a4d2,local-authorityabc": "1",
212-
",article-4-direction-area,1,local-authorityabc": "2",
213-
}
214-
issues = IssueLog()
215-
redirect_lookups = {"1": {"entity": "", "status": "410"}}
216-
217-
phase = LookupPhase(
218-
lookups=lookups,
219-
redirect_lookups=redirect_lookups,
220-
issue_log=issues,
221-
provision_summary_dir="var/cache/provision-summary/",
222-
)
223-
phase.entity_field = "entity"
224-
mock_df = pd.DataFrame(
225-
{
226-
"organisation": ["local-authority:ABC"],
227-
"dataset": ["article-4-direction"],
228-
}
229-
)
230-
mocker.patch("pandas.read_csv", return_value=mock_df)
231-
output = [block for block in phase.process(input_stream)]
232-
233-
assert output[0]["row"]["entity"] == "2"
234-
assert (
235-
issues.rows[0]["issue-type"]
236-
== "no associated documents found for this area"
237-
)
238-
assert issues.rows[0]["value"] == "a4d2"
239-
240126

241127
class TestPrintLookupPhase:
242128
def test_process_does_not_produce_new_lookup(self, get_input_stream, get_lookup):

0 commit comments

Comments
 (0)