Skip to content

Commit

Permalink
- Plugin base for example
Browse files Browse the repository at this point in the history
- default add tags on import instead of set
  • Loading branch information
godicked committed Mar 8, 2024
1 parent e0ebd3d commit ceaff2c
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 139 deletions.
7 changes: 5 additions & 2 deletions panoptic_back/panoptic/core/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

if TYPE_CHECKING:
from panoptic.core.project.project import Project
from panoptic.models import PropertyType, PropertyMode, PropertyDescription, Tag, Property, ImportOptions
from panoptic.models import PropertyType, PropertyMode, PropertyDescription, Tag, Property, ImportOptions, SetMode


def parse_list(value: str):
Expand Down Expand Up @@ -111,7 +111,10 @@ async def import_file(self, options: ImportOptions):
name_to_tag[tag.value] = tag
# replace tag names by tag ids
values = [[name_to_tag[t].id for t in v] if v else None for v in values]
await self.project.db.set_property_values_array(prop_id, ids, values)
for id_, value in zip(ids, values):
await self.project.db.set_tag_property_value(prop_id, [id_], value, SetMode.add)
else:
await self.project.db.set_property_values_array(prop_id, ids, values)

async def analyse_file(self):
# TODO: refactor all this to use pandas methods properly
Expand Down
1 change: 0 additions & 1 deletion panoptic_back/panoptic/core/task/load_plugin_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ async def run(self):
plugin = plugin_module.plugin_class(self.project, self.path)
await plugin.start()
self.project.plugins.append(plugin)
# print(plugin.get_description())

async def run_if_last(self):
await self.project.update_actions_from_db()
Expand Down
3 changes: 3 additions & 0 deletions panoptic_back/panoptic/plugins/PluginBase/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .plugin_base import PluginBase

plugin_class = PluginBase
25 changes: 25 additions & 0 deletions panoptic_back/panoptic/plugins/PluginBase/plugin_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from pathlib import Path

from pydantic import BaseModel

from panoptic.core.project.project import Project
from panoptic.models import ActionContext
from panoptic.plugin import Plugin


class TestParams(BaseModel):
eau: str = None
terre: int = 0
feu: float = 2.4
air: Path = None


class PluginBase(Plugin):
def __init__(self, project: Project, plugin_path: str):
super().__init__(name='TestPlugin1', project=project, plugin_path=plugin_path)
self.params = TestParams()

self.project.action.group_images.register(self, self.firefly)

async def firefly(self, context: ActionContext, damage: int):
pass
3 changes: 0 additions & 3 deletions panoptic_back/panoptic/plugins/TestPlugin1/__init__.py

This file was deleted.

62 changes: 0 additions & 62 deletions panoptic_back/panoptic/plugins/TestPlugin1/test_plugin.py

This file was deleted.

3 changes: 0 additions & 3 deletions panoptic_back/panoptic/plugins/TestPlugin2/__init__.py

This file was deleted.

55 changes: 0 additions & 55 deletions panoptic_back/panoptic/plugins/TestPlugin2/test_plugin.py

This file was deleted.

4 changes: 2 additions & 2 deletions panoptic_back/panoptic/scripts/convert_old_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from panoptic.core.project.project import Project
from panoptic.utils import clean_value

source_db_file = '/Users/david/Downloads/panoptic_cat.db'
target_folder = '/Users/david/panoptic-projects/panoptic_cat'
source_db_file = '/Users/david/Downloads/panoptic-edouard.db'
target_folder = '/Users/david/panoptic-projects/panoptic-edouard'


async def run():
Expand Down
2 changes: 1 addition & 1 deletion panoptic_front/src/components/modals/image/Similarity.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { GroupManager } from '@/core/GroupManager';
import { Image, SearchResult } from '@/data/models';
import { computed, onMounted, reactive, ref, watch } from 'vue';
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue';
import wTT from '@/components/tooltips/withToolTip.vue'
import TreeScroller from '@/components/scrollers/tree/TreeScroller.vue';
import RangeInput from '@/components/inputs/RangeInput.vue';
Expand Down
23 changes: 14 additions & 9 deletions panoptic_front/src/data/panopticStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,22 @@ export const usePanopticStore = defineStore('panopticStore', () => {
async function init() {
// console.log('init')
data.init = false
data.status = await apiGetStatus()
data.plugins = await apiGetPlugins()
data.init = true
// console.log('end init')
if(data.status.isLoaded) {
project.init()
try {
data.status = await apiGetStatus()
data.plugins = await apiGetPlugins()
data.init = true
// console.log('end init')
if (data.status.isLoaded) {
project.init()
}
}
catch {
setTimeout(() => init(), 1000)
}
}

async function loadProject(path: string, noCall?: boolean) {
if(!noCall) {
if (!noCall) {
data.status = await apiLoadProject(path)
}
// console.log(data.status)
Expand All @@ -62,7 +67,7 @@ export const usePanopticStore = defineStore('panopticStore', () => {
router.push('/')
}

async function deleteProject(path:string) {
async function deleteProject(path: string) {
data.status = await apiDeleteProject(path)
}

Expand Down Expand Up @@ -94,7 +99,7 @@ export const usePanopticStore = defineStore('panopticStore', () => {
}

async function addPlugin(path) {
if(!path) return
if (!path) return
await apiAddPlugin(path)
data.plugins = await apiGetPlugins()
}
Expand Down
5 changes: 4 additions & 1 deletion panoptic_front/src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ onMounted(() => {
</div>
</div>
</div>
<div class="main-menu flex-grow-1">
<div v-if="panoptic.data.init" class="main-menu flex-grow-1">
<div class="icon">👀</div>
<h1 class="m-0 p-0">Panoptic</h1>
<h6 class="dimmed-2">Version pre-2.0</h6>
Expand All @@ -96,6 +96,9 @@ onMounted(() => {
</div>
</div>
</div>
<div v-else class="text-center mt-5 w-100">
<p>Waiting for Server...</p>
</div>
</div>
</template>

Expand Down

0 comments on commit ceaff2c

Please sign in to comment.