Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit 9f159dc

Browse files
authored
repo: Rename to record
Fixes: #361 Fixes: #393
1 parent e55843c commit 9f159dc

File tree

71 files changed

+912
-880
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+912
-880
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Notes on development dependencies in `setup.py` files to codebase notes.
1111
- Test for `cached_download`
1212
### Changed
13+
- `repo`/`Repo` to `record`/`Record`
1314
- Definitions with a `spec` can use the `subspec` parameter to declare that they
1415
are a list or a dict where the values are of the `spec` type. Rather than the
1516
list or dict itself being of the `spec` type.

dffml/cli/cli.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pkg_resources
88

99
from ..version import VERSION
10-
from ..repo import Repo
10+
from ..record import Record
1111
from ..source.source import BaseSource
1212
from ..util.packaging import is_develop
1313
from ..util.cli.arg import Arg
@@ -37,40 +37,42 @@ async def run(self):
3737

3838
class Edit(SourcesCMD, KeysCMD):
3939
"""
40-
Edit each specified repo
40+
Edit each specified record
4141
"""
4242

4343
async def run(self):
4444
async with self.sources as sources:
4545
async with sources() as sctx:
4646
for key in self.keys:
47-
repo = await sctx.repo(key)
47+
record = await sctx.record(key)
4848
pdb.set_trace()
49-
await sctx.update(repo)
49+
await sctx.update(record)
5050

5151

5252
class Merge(CMD):
5353
"""
54-
Merge repo data between sources
54+
Merge record data between sources
5555
"""
5656

5757
arg_dest = Arg(
58-
"dest", help="Sources merge repos into", type=BaseSource.load_labeled
58+
"dest", help="Sources merge records into", type=BaseSource.load_labeled
5959
)
6060
arg_src = Arg(
61-
"src", help="Sources to pull repos from", type=BaseSource.load_labeled
61+
"src",
62+
help="Sources to pull records from",
63+
type=BaseSource.load_labeled,
6264
)
6365

6466
async def run(self):
6567
async with self.src.withconfig(
6668
self.extra_config
6769
) as src, self.dest.withconfig(self.extra_config) as dest:
6870
async with src() as sctx, dest() as dctx:
69-
async for src in sctx.repos():
70-
repo = Repo(src.key)
71-
repo.merge(src)
72-
repo.merge(await dctx.repo(repo.key))
73-
await dctx.update(repo)
71+
async for src in sctx.records():
72+
record = Record(src.key)
73+
record.merge(src)
74+
record.merge(await dctx.record(record.key))
75+
await dctx.update(record)
7476

7577

7678
class ImportExportCMD(PortCMD, SourcesCMD):
@@ -80,7 +82,7 @@ class ImportExportCMD(PortCMD, SourcesCMD):
8082

8183

8284
class Import(ImportExportCMD):
83-
"""Imports repos"""
85+
"""Imports records"""
8486

8587
async def run(self):
8688
async with self.sources as sources:
@@ -89,7 +91,7 @@ async def run(self):
8991

9092

9193
class Export(ImportExportCMD):
92-
"""Exports repos"""
94+
"""Exports records"""
9395

9496
async def run(self):
9597
async with self.sources as sources:

dffml/cli/dataflow.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ class RunCMD(SourcesCMD):
9797
arg_sources = SourcesCMD.arg_sources.modify(required=False)
9898
arg_caching = Arg(
9999
"-caching",
100-
help="Skip running DataFlow if a repo already contains these features",
100+
help="Skip running DataFlow if a record already contains these features",
101101
nargs="+",
102102
required=False,
103103
default=[],
104104
)
105105
arg_no_update = Arg(
106106
"-no-update",
107-
help="Update repo with sources",
107+
help="Update record with sources",
108108
required=False,
109109
default=False,
110110
action="store_true",
@@ -134,42 +134,42 @@ class RunCMD(SourcesCMD):
134134
nargs="+",
135135
action=ParseInputsAction,
136136
default=[],
137-
help="Other inputs to add under each ctx (repo's key will "
137+
help="Other inputs to add under each ctx (record's key will "
138138
+ "be used as the context)",
139139
)
140-
arg_repo_def = Arg(
141-
"-repo-def",
140+
arg_record_def = Arg(
141+
"-record-def",
142142
default=False,
143143
type=str,
144-
help="Definition to be used for repo.key."
145-
+ "If set, repo.key will be added to the set of inputs "
146-
+ "under each context (which is also the repo's key)",
144+
help="Definition to be used for record.key."
145+
+ "If set, record.key will be added to the set of inputs "
146+
+ "under each context (which is also the record's key)",
147147
)
148148

149149
def __init__(self, *args, **kwargs):
150150
super().__init__(*args, **kwargs)
151151
self.orchestrator = self.orchestrator.withconfig(self.extra_config)
152152

153153

154-
class RunAllRepos(RunCMD):
155-
"""Run dataflow for all repos in sources"""
154+
class RunAllRecords(RunCMD):
155+
"""Run dataflow for all records in sources"""
156156

157-
async def repos(self, sctx):
157+
async def records(self, sctx):
158158
"""
159-
This method exists so that it can be overriden by RunRepoSet
159+
This method exists so that it can be overriden by RunRecordSet
160160
"""
161-
async for repo in sctx.repos():
162-
yield repo
161+
async for record in sctx.records():
162+
yield record
163163

164164
async def run_dataflow(self, orchestrator, sources, dataflow):
165165
# Orchestrate the running of these operations
166166
async with orchestrator(dataflow) as octx, sources() as sctx:
167167
# Add our inputs to the input network with the context being the
168-
# repo key
168+
# record key
169169
inputs = []
170-
async for repo in self.repos(sctx):
171-
# Skip running DataFlow if repo already has features
172-
existing_features = repo.features()
170+
async for record in self.records(sctx):
171+
# Skip running DataFlow if record already has features
172+
existing_features = record.features()
173173
if self.caching and all(
174174
map(
175175
lambda cached: cached in existing_features,
@@ -178,19 +178,19 @@ async def run_dataflow(self, orchestrator, sources, dataflow):
178178
):
179179
continue
180180

181-
repo_inputs = []
181+
record_inputs = []
182182
for value, def_name in self.inputs:
183-
repo_inputs.append(
183+
record_inputs.append(
184184
Input(
185185
value=value,
186186
definition=dataflow.definitions[def_name],
187187
)
188188
)
189-
if self.repo_def:
190-
repo_inputs.append(
189+
if self.record_def:
190+
record_inputs.append(
191191
Input(
192-
value=repo.key,
193-
definition=dataflow.definitions[self.repo_def],
192+
value=record.key,
193+
definition=dataflow.definitions[self.record_def],
194194
)
195195
)
196196

@@ -199,8 +199,8 @@ async def run_dataflow(self, orchestrator, sources, dataflow):
199199
inputs.append(
200200
MemoryInputSet(
201201
MemoryInputSetConfig(
202-
ctx=StringInputSetContext(repo.key),
203-
inputs=repo_inputs,
202+
ctx=StringInputSetContext(record.key),
203+
inputs=record_inputs,
204204
)
205205
)
206206
)
@@ -212,14 +212,14 @@ async def run_dataflow(self, orchestrator, sources, dataflow):
212212
*inputs, strict=not self.no_strict
213213
):
214214
ctx_str = (await ctx.handle()).as_string()
215-
# TODO(p4) Make a RepoInputSetContext which would let us
216-
# store the repo instead of recalling it by the URL
217-
repo = await sctx.repo(ctx_str)
215+
# TODO(p4) Make a RecordInputSetContext which would let us
216+
# store the record instead of recalling it by the URL
217+
record = await sctx.record(ctx_str)
218218
# Store the results
219-
repo.evaluated(results)
220-
yield repo
219+
record.evaluated(results)
220+
yield record
221221
if not self.no_update:
222-
await sctx.update(repo)
222+
await sctx.update(record)
223223

224224
async def run(self):
225225
dataflow_path = pathlib.Path(self.dataflow)
@@ -232,35 +232,35 @@ async def run(self):
232232
exported = await loader.loadb(dataflow_path.read_bytes())
233233
dataflow = DataFlow._fromdict(**exported)
234234
async with self.orchestrator as orchestrator, self.sources as sources:
235-
async for repo in self.run_dataflow(
235+
async for record in self.run_dataflow(
236236
orchestrator, sources, dataflow
237237
):
238-
yield repo
238+
yield record
239239

240240

241-
class RunRepoSet(RunAllRepos, KeysCMD):
242-
"""Run dataflow for single repo or set of repos"""
241+
class RunRecordSet(RunAllRecords, KeysCMD):
242+
"""Run dataflow for single record or set of records"""
243243

244-
async def repos(self, sctx):
244+
async def records(self, sctx):
245245
for key in self.keys:
246-
yield await sctx.repo(key)
246+
yield await sctx.record(key)
247247

248248
def __init__(self, *args, **kwargs):
249249
super().__init__(*args, **kwargs)
250250
self.sources = SubsetSources(*self.sources, keys=self.keys)
251251

252252

253-
class RunRepos(CMD):
254-
"""Run DataFlow and assign output to a repo"""
253+
class RunRecords(CMD):
254+
"""Run DataFlow and assign output to a record"""
255255

256-
_set = RunRepoSet
257-
_all = RunAllRepos
256+
_set = RunRecordSet
257+
_all = RunAllRecords
258258

259259

260260
class Run(CMD):
261261
"""Run dataflow"""
262262

263-
repos = RunRepos
263+
records = RunRecords
264264

265265

266266
class Diagram(CMD):

dffml/cli/list.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
from ..util.cli.cmds import SourcesCMD, ListEntrypoint
77

88

9-
class ListRepos(SourcesCMD):
9+
class ListRecords(SourcesCMD):
1010
"""
11-
List repos stored in sources
11+
List records stored in sources
1212
"""
1313

1414
async def run(self):
1515
async with self.sources as sources:
1616
async with sources() as sctx:
17-
async for repo in sctx.repos():
18-
print(repo)
17+
async for record in sctx.records():
18+
print(record)
1919

2020

2121
class ListServices(ListEntrypoint):
@@ -48,10 +48,10 @@ class ListModels(ListEntrypoint):
4848

4949
class List(CMD):
5050
"""
51-
List repos and installed interfaces
51+
List records and installed interfaces
5252
"""
5353

54-
repos = ListRepos
54+
records = ListRecords
5555
sources = ListSources
5656
models = ListModels
5757
services = ListServices

dffml/cli/ml.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,29 @@ class PredictAll(MLCMD):
3838

3939
arg_update = Arg(
4040
"-update",
41-
help="Update repo with sources",
41+
help="Update record with sources",
4242
required=False,
4343
default=False,
4444
action="store_true",
4545
)
4646

4747
async def run(self):
48-
async for repo in predict(
49-
self.model, self.sources, update=self.update, keep_repo=True
48+
async for record in predict(
49+
self.model, self.sources, update=self.update, keep_record=True
5050
):
51-
yield repo
51+
yield record
5252

5353

54-
class PredictRepo(PredictAll, KeysCMD):
55-
"""Predictions for individual repos"""
54+
class PredictRecord(PredictAll, KeysCMD):
55+
"""Predictions for individual records"""
5656

5757
def __init__(self, *args, **kwargs):
5858
super().__init__(*args, **kwargs)
5959
self.sources = SubsetSources(*self.sources, keys=self.keys)
6060

6161

6262
class Predict(CMD):
63-
"""Evaluate features against repos and produce a prediction"""
63+
"""Evaluate features against records and produce a prediction"""
6464

65-
repo = PredictRepo
65+
record = PredictRecord
6666
_all = PredictAll

dffml/feature/feature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async def inc(self, key, default=None, by=1):
6363

6464
class Data(Task):
6565
"""
66-
Passed to each feature during evaluation. Shared between all features a repo
66+
Passed to each feature during evaluation. Shared between all features a record
6767
is being evaluated with
6868
"""
6969

0 commit comments

Comments
 (0)