Beispiel #1
0
    def test_resuming_project(self, environment):
        exp = neptune.init_project(name=environment.project)

        key = self.gen_key()
        val = fake.word()
        exp[key] = val
        exp.sync()

        exp.stop()

        exp2 = neptune.init_project(name=environment.project)
        assert exp2[key].fetch() == val
Beispiel #2
0
    def test_init_and_readonly(self, environment):
        project: Project = neptune.init_project(name=environment.project)

        key = f"{self.gen_key()}-" + "-".join((fake.word() for _ in range(4)))
        val = fake.word()
        project[key] = val
        project.sync()
        project.stop()

        read_only_project = neptune.get_project(name=environment.project)
        read_only_project.sync()

        assert set(read_only_project.get_structure()["sys"]) == {
            "creation_time",
            "id",
            "modification_time",
            "monitoring_time",
            "name",
            "ping_time",
            "running_time",
            "size",
            "state",
            "tags",
            "visibility",
        }
        assert read_only_project[key].fetch() == val
Beispiel #3
0
def container(request, environment):
    if request.param == "project":
        project = neptune.init_project(name=environment.project)
        yield project
        project.stop()

    if request.param == "run":
        exp = neptune.init_run(project=environment.project)
        yield exp
        exp.stop()
Beispiel #4
0
    def test_copy_project_to_container(self, container: Run, value, environment):
        project = neptune.init_project(name=environment.project)

        src, destination, destination2 = self.gen_key(), self.gen_key(), self.gen_key()

        project[src] = value
        project.sync()

        container[destination] = project[src]
        container[destination2] = container[destination]
        container.sync()

        assert project[src].fetch() == value
        assert container[destination].fetch() == value
        assert container[destination2].fetch() == value
Beispiel #5
0
    def test_read_only_mode(self):
        project = init_project(name=self.PROJECT_NAME, mode="read-only")

        with self.assertLogs() as caplog:
            project["some/variable"] = 13
            project["some/other_variable"] = 11
            self.assertEqual(
                caplog.output,
                [
                    "WARNING:neptune.new.internal.operation_processors.read_only_operation_processor:"
                    "Client in read-only mode, nothing will be saved to server."
                ],
            )

        self.assertEqual(42, project["some/variable"].fetch())
        self.assertNotIn(str(project._id), os.listdir(".neptune"))
Beispiel #6
0
 def test_async_mode(self):
     with init_project(name=self.PROJECT_NAME,
                       mode="async",
                       flush_period=0.5) as project:
         project["some/variable"] = 13
         with self.assertRaises(MetadataInconsistency):
             project["some/variable"].fetch()
         project.wait()
         self.assertEqual(13, project["some/variable"].fetch())
         self.assertIn(str(project._id), os.listdir(".neptune/async"))
         execution_dir = os.listdir(".neptune/async/{}".format(
             project._id))[0]
         self.assertIn(
             "data-1.log",
             os.listdir(".neptune/async/{}/{}".format(
                 project._id, execution_dir)),
         )
Beispiel #7
0
    def test_sync_project(self, environment):
        with tmp_context() as tmp:
            # with test values
            key = f"{self.gen_key()}-" + "-".join((fake.word() for _ in range(3)))
            original_value = fake.word()
            updated_value = fake.word()

            # init run
            project = neptune.init_project(name=environment.project)

            def get_next_project():
                return neptune.init_project(name=environment.project)

            self._test_sync(
                exp=project,
                get_next_exp=get_next_project,
                path=tmp,
                key=key,
                original_value=original_value,
                updated_value=updated_value,
            )
Beispiel #8
0
    def test_fetch_table(self, environment):
        tag = str(uuid.uuid4())
        with neptune.init(project=environment.project) as run:
            run["sys/tags"].add(tag)
            run["value"] = 12

        with neptune.init(project=environment.project) as run:
            run["sys/tags"].add(tag)
            run["another/value"] = "testing"

        # wait for the elasticsearch cache to fill
        time.sleep(5)

        project = neptune.init_project(name=environment.project)

        runs_table = sorted(
            project.fetch_runs_table(tag=tag).to_runs(),
            key=lambda r: r.get_attribute_value("sys/id"),
        )
        assert len(runs_table) == 2
        assert runs_table[0].get_attribute_value("value") == 12
        assert runs_table[1].get_attribute_value("another/value") == "testing"
Beispiel #9
0
 def get_next_project():
     return neptune.init_project(name=environment.project)
Beispiel #10
0
    def test_project_name_env_var(self):
        os.environ[PROJECT_ENV_NAME] = self.PROJECT_NAME

        project = init_project(mode="sync")
        project["some/variable"] = 13
        self.assertEqual(13, project["some/variable"].fetch())
Beispiel #11
0
 def test_inexistent_project(self):
     with self.assertRaises(NeptuneMissingProjectNameException):
         init_project(mode="async")
Beispiel #12
0
 def test_sync_mode(self):
     project = init_project(name=self.PROJECT_NAME, mode="sync")
     project["some/variable"] = 13
     self.assertEqual(13, project["some/variable"].fetch())
     self.assertNotIn(str(project._id), os.listdir(".neptune"))
Beispiel #13
0
 def test_offline_mode_for_project(self):
     with self.assertRaises(NeptuneException):
         init_project(name=self.PROJECT_NAME, mode="offline")
Beispiel #14
0
 def test_incorrect_mode(self):
     with self.assertRaises(ValueError):
         init_project(name=self.PROJECT_NAME, mode="srtgj")