Skip to content

Commit 76879f1

Browse files
committed
Revert "update"
This reverts commit 374ba40.
1 parent 374ba40 commit 76879f1

2 files changed

Lines changed: 43 additions & 13 deletions

File tree

src/datacustomcode/run.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,16 @@ def run_entrypoint(
7676
f"Please ensure config.json contains a 'dataspace' field."
7777
)
7878

79-
# Load config file (if provided)
79+
# Load config file first (if provided) so that dataspace from config.json
80+
# can override any dataspace in the config file
8081
if config_file:
8182
config.load(config_file)
8283

84+
# Add dataspace to reader and writer config options
85+
# (after loading config file to ensure it takes precedence)
86+
_set_config_option(config.reader_config, "dataspace", dataspace)
87+
_set_config_option(config.writer_config, "dataspace", dataspace)
88+
8389
if profile != "default":
8490
_set_config_option(config.reader_config, "credentials_profile", profile)
8591
_set_config_option(config.writer_config, "credentials_profile", profile)

tests/test_run.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,25 @@ class TestDataspaceScenarios:
241241
"""Test dataspace functionality in run_entrypoint."""
242242

243243
def test_run_entrypoint_with_default_dataspace(self):
244-
"""Test that run_entrypoint runs successfully with dataspace='default'."""
244+
"""Test that run_entrypoint sets dataspace='default' correctly."""
245245
with tempfile.NamedTemporaryFile(suffix=".py", delete=False) as temp:
246246
entrypoint_content = textwrap.dedent(
247247
"""
248-
# Test entrypoint - just verify it runs
248+
# Test entrypoint
249+
from datacustomcode.config import config
249250
with open("dataspace_output.txt", "w") as f:
250-
f.write("Entrypoint executed successfully\\n")
251+
rds = (
252+
config.reader_config.options.get("dataspace")
253+
if config.reader_config
254+
else None
255+
)
256+
wds = (
257+
config.writer_config.options.get("dataspace")
258+
if config.writer_config
259+
else None
260+
)
261+
f.write(f"Reader dataspace: {rds}\\n")
262+
f.write(f"Writer dataspace: {wds}\\n")
251263
"""
252264
)
253265
temp.write(entrypoint_content.encode("utf-8"))
@@ -266,10 +278,11 @@ def test_run_entrypoint_with_default_dataspace(self):
266278
profile="default",
267279
)
268280

269-
# Verify entrypoint executed
281+
# Verify dataspace was set
270282
with open("dataspace_output.txt", "r") as f:
271283
content = f.read()
272-
assert "Entrypoint executed successfully" in content
284+
assert "Reader dataspace: default" in content
285+
assert "Writer dataspace: default" in content
273286

274287
finally:
275288
if os.path.exists(entrypoint_file):
@@ -280,14 +293,26 @@ def test_run_entrypoint_with_default_dataspace(self):
280293
os.unlink("dataspace_output.txt")
281294

282295
def test_run_entrypoint_with_custom_dataspace(self):
283-
"""Test that run_entrypoint runs successfully with custom dataspace."""
296+
"""Test that run_entrypoint sets custom dataspace correctly."""
284297
custom_dataspace = "dataspace-1"
285298
with tempfile.NamedTemporaryFile(suffix=".py", delete=False) as temp:
286299
entrypoint_content = textwrap.dedent(
287300
"""
288-
# Test entrypoint - just verify it runs
301+
# Test entrypoint
302+
from datacustomcode.config import config
289303
with open("dataspace_output.txt", "w") as f:
290-
f.write("Entrypoint executed successfully\\n")
304+
rds = (
305+
config.reader_config.options.get("dataspace")
306+
if config.reader_config
307+
else None
308+
)
309+
wds = (
310+
config.writer_config.options.get("dataspace")
311+
if config.writer_config
312+
else None
313+
)
314+
f.write(f"Reader dataspace: {rds}\\n")
315+
f.write(f"Writer dataspace: {wds}\\n")
291316
"""
292317
)
293318
temp.write(entrypoint_content.encode("utf-8"))
@@ -299,19 +324,18 @@ def test_run_entrypoint_with_custom_dataspace(self):
299324
json.dump({"dataspace": custom_dataspace}, f)
300325

301326
try:
302-
# Verify entrypoint runs successfully with custom dataspace
303-
# (if dataspace validation failed, this would raise an error)
304327
run_entrypoint(
305328
entrypoint=entrypoint_file,
306329
config_file=None,
307330
dependencies=[],
308331
profile="default",
309332
)
310333

311-
# Verify entrypoint executed
334+
# Verify custom dataspace was set
312335
with open("dataspace_output.txt", "r") as f:
313336
content = f.read()
314-
assert "Entrypoint executed successfully" in content
337+
assert f"Reader dataspace: {custom_dataspace}" in content
338+
assert f"Writer dataspace: {custom_dataspace}" in content
315339

316340
finally:
317341
if os.path.exists(entrypoint_file):

0 commit comments

Comments
 (0)