Skip to content

Commit

Permalink
Disable relation file linking by default
Browse files Browse the repository at this point in the history
  • Loading branch information
frthjf committed Jun 30, 2024
1 parent c8ce73d commit 5d1c82e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
7 changes: 5 additions & 2 deletions src/machinable/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,12 @@ def _wrapper(
belongs_to_many = _relation(BelongsToMany)


def _uuid_symlink(directory, uuid, mode="file"):
dst = os.path.join(directory, id_from_uuid(uuid))
def _uuid_symlink(directory, uuid, mode=None):
dst = os.path.join(directory, "related", id_from_uuid(uuid))
try:
if mode is None:
return uuid

os.makedirs(dst, exist_ok=True)
if mode == "file":
with open(os.path.join(dst, "link"), "w") as f:
Expand Down
25 changes: 14 additions & 11 deletions tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,22 @@ def test_interface_to_directory(tmp_path):
)


def test_interface_to_directory_inverse_relations(tmp_storage):
def test_interface_to_dir_inverse_relations(tmp_storage):
a = Interface()
b = Interface(uses=a)
b.commit()

assert a.used_by[0] == b

def _related(interface, expected):
x = sorted(os.listdir(interface.local_directory("related")))
try:
x.remove("metadata.jsonl")
except:
pass
x = sorted(
[
d
for d in os.listdir(interface.local_directory("related"))
if d != "metadata.jsonl"
and not os.path.isdir(interface.local_directory("related", d))
]
)
assert x == expected

_related(b, ["uses"])
Expand Down Expand Up @@ -272,13 +275,13 @@ def test_interface_modifiers(tmp_storage):
project.__exit__()


def test_symlink_relations(tmp_storage):
project = Project("./tests/samples/project").__enter__()
# def test_symlink_relations(tmp_storage):
# project = Project("./tests/samples/project").__enter__()

component = get("dummy").launch()
assert os.path.isfile(component.execution.component_directory("link"))
# component = get("dummy").launch()
# assert os.path.isfile(component.execution.local_directory("related", component.id, "link"))

project.__exit__()
# project.__exit__()


def test_interface_hash(tmp_storage):
Expand Down

0 comments on commit 5d1c82e

Please sign in to comment.