1

Problem with the core update and the deregistering of the assets on shotgun with the asset folders on disc

Hi guys! Happy New Year and hope you are all well!

We are having an issue with a few assets we are trying to upload. We wondering what the best action was to take as we think the problem we are having is with the core update and the linking / registering of the assets on shotgun with the asset folders on disc.

We have deleted a few old assets on disc and on shotgun with our tools. We have then proceeded to upload new assets again that have the same name and they seem to not be able to be created because of the old registered link with the folder on disc. We can create them and version up past the last deleted assets, though not create them newly starting at v001 as they have this link stored somewhere.

We were just wondering in the shell core command, "unregister folders" was the correct way to go here. If this is the correct way to go then is there an API command for this as we will need to run it in our tools on delete.

 

# The Error
File "z:\shotgun\software\sgtk\studio\install\core\python\tank\folder\operations.py", line 214, in process_filesystem_structurefolders_created = io_receiver.execute_folder_creation()

File "z:\shotgun\software\sgtk\studio\install\core\python\tank\folder\folder_io.py", line 172, in execute_folder_creation raise TankError("Folder creation aborted: %s" % e)

tank.errors.TankError: Folder creation aborted: The path 'Z:\shotgun\mclaren\p13\pdm_p13\assets\mcl_p13_ext_alloy_wheel_cast_lwff_frt_rhs_a001' cannot be processed because it is already associated with Asset 'mcl_p13_ext_alloy_wheel_cast_lwff_frt_rhs_a001' (id 89551) in Shotgun. You are now trying to associate it with Asset 'mcl_p13_ext_alloy_wheel_cast_lwff_frt_rhs_a001' (id 90151). If you want to unregister your previously created folders, you can run the following command: 'tank Asset mcl_p13_ext_alloy_wheel_cast_lwff_frt_rhs_a001 unregister_folders'

 

 

Thanks for your time!

Nick

댓글 15개

  • 0
    Avatar
    Philip Scadding

    Hi

    I'm looking into this on behalf of Nick at the moment.

    I see can just import the following.

    sgtk.deploy.tank_commands.path_cache.UnregisterFoldersAction

    But it only has a function called "run_interactive", and we don't want to run it in an interactive mode, its also not clear without more investigation exactly what it wants me to provide it with in terms of arguments.

    Is it easier for us to dynamically create command line calls to batch unregister entities, rather than doing it in a pythonic way?  This is obviously not in the api and presumably not intended to be, so this probably isn't the prefered way of doing things.

    Normally if everything goes well we would never want to remove entities, but sometimes we do need to and in bulk. So we really need a neat method for unregistering a good number of entities. Even better would be a method for unregistering and removing from disk the given entities.

    Any ideas or thoughts?

     

    Thanks

    Phil

  • 0
    Avatar
    Manne Öhrström

    Hello Phil!

    Sorry about that - looks like that tank command doesn't have the API support enabled at the moment!

    Normally, you would access this via the Tank Command API documented here.

    I'll make a ticket on our end and we'll try to add support for this as soon as we can!

    thanks!
    manne

  • 0
    Avatar
    Philip Scadding

    Ok Brilliant,

    Thanks

    Manne

  • 0
    Avatar
    Philip Scadding

    Another thing related to this.

    When it fails to create the folder, it gives me the following message

    "If you want to unregister your previously created folders, you can run the following command: 'tank Asset test_cad_a002 unregister_folders'"

    But presumably it its much safer to do it by id instead of name because you might have entities with the same name, and then you don't know which it will unregister. Could it give the example with the id instead? I have bunch of these to go through and it would have been easier if I could have just copied this code.

    Thanks

    Phil

  • 0
    Avatar
    Manne Öhrström

    Hey Phil!

    The tank command does a bunch of checks to ensure that there is uniqueness. You could start the command with the form tank Asset @1234 unregister_folders which would be explicit (but also harder to read), but if you had two items named the same in Shotgun, it would give you a warning message and a summary of which ids that you can choose from – something like this:

    Mannes-MacBook-Pro-2:flame_tech_demo manne$ ./tank Shot aa001 unregister_folders
    
    Welcome to the Shotgun Pipeline Toolkit!
    For documentation, see https://toolkit.shotgunsoftware.com
    - You are running a project specific tank command. Only items that are part of
    this project will be considered.
    
    More than one item matching your input:
    
     [@1510] Shot aa001_001 (Flame Tech Demo)
             Created by the Shotgun Flame exporter.
    
     [@1511] Shot aa001_002 (Flame Tech Demo)
             Created by the Shotgun Flame exporter.
    
     [@1512] Shot aa001_003 (Flame Tech Demo)
             Created by the Shotgun Flame exporter.
    
    More than one item matched your search phrase 'aa001'! Please enter a more
    specific search phrase in order to narrow it down to a single match. If there
    are several items with the same name, you can use the @id field displayed to
    specify a particular object (e.g. 'Shot @123').
    
    
    ERROR: Please try again with a more specific search!
    

     

    I like how it's using the name rather than the id because it makes it very easy to understand which item is being referred to. Then, if there is any risk of ambiguity, this will be caught by the tank command. For the API implementation however, it will be id based for sure, that should definitely be very explicit. Does that make sense?

    Thanks!
    Manne

  • 0
    Avatar
    Philip Scadding

    Ah ok thats fine then. No problem

    I obviously hadn't come across an example where there would be a name clash, so I hadn't seen that. I was using it in fear. :-)

     

  • 0
    Avatar
    KP

    We just released v0.15.20 of the Toolkit Core which has fixes and new functionality for the unregister_folders command. It also adds API support for the command as requested. 

    Let us know if you have any questions!

    cheers,
    kp

  • 0
    Avatar
    Philip Scadding

    Ah superb! That'll be very helpful. Hopefully this should save us a lot of time.

    Thanks

  • 0
    Avatar
    Philip Scadding

    One question I have still.

    Can the folders now be unregistered after the shotgun asset has been deleted, or does it still need to be done before the asset can be removed?

    thanks

  • 0
    Avatar
    Manne Öhrström

    Hey!

    Yes! Shotgun assets can be deleted, the new unregister command will still work ok! You have to use the path based syntax though, for example

    tank unregister_folders /path/to/deleted_asset
    

     

  • 0
    Avatar
    Philip Scadding

    Thanks Manne

    I've tried the new unregister through the command line, and what was taking a whole working day now only takes about 20 mins. So thats great.

    You said this is also in the api, but I can't see it in the documentation, has it not been added to the documentation yet or should I access this through the SGTKSytemCommand class? if so I've never used that before I'll have to check it out.

  • 0
    Avatar
    Manne Öhrström

    Hey!

    Yepp, there is API support as part of our standard, introspective tank command API - here's an example how to use it:

    # In the example below, tk is a sgtk API instance for a given project
    
    # you can list the available tank commands:
    >>> tk.list_commands()
    ['setup_project', 'setup_project_factory', 'core', 'localize', 'share_core', 'attach_to_core', 'validate', 'cache_apps', 'clear_shotgun_menu_cache', 'app_info', 'install_app', 'install_engine', 'updates', 'configurations', 'synchronize_folders', 'unregister_folders', 'clone_configuration', 'copy_apps']
    
    
    # you can construct a command instance:
    >>> cmd = tk.get_command("unregister_folders")
    
    # you can introspect metadata:
    >>> print cmd.description
    Unregisters the folders for an object in Shotgun.
    
    >>> print cmd.name
    unregister_folders
    
    >>> pprint.pprint(cmd.parameters)
    {'entity': {'default': None,
                'description': "Entity to unregister. Should be a Shotgun-style entity dictionary with keys 'type' and 'id'.",
                'type': 'dict'},
     'path': {'default': None,
              'description': 'Path to unregister. Any child paths will be unregistered too.',
              'type': 'str'},
     'return_value': {'description': 'List of dictionaries where each dict contains the path and entity data for an unregistered path',
                      'type': 'list'}}
    
    # the above syntax means that you *either* specify a path or an entity as input
    # parameters to the command. You do this when you execute the execute() method.
    # For example:
    >>> cmd.execute({"path": "/foo/bar"})
    WARNING Path '/foo/bar' is not registered in Shotgun - ignoring.
    INFO No associated folders found!
    []
    
    

     

    Hope that helps! Any questions, let us know!

    Thanks!
    Manne

     

     

  • 0
    Avatar
    Philip Scadding

    Fantastic, Thanks again, and you for you quick response!

  • 0
    Avatar
    Philip Scadding

    Hi Manne

    With the api approach I can't see anyway to provide a list of entities or paths other than calling execute in a loop. This currently seems quite a lot slower than the command line approach. Am I missing anything or is this a limitation of the api? I'm currently trying to unregister all assets but nothing else.

    thanks

  • 0
    Avatar
    Manne Öhrström

    Hi!

    Yes, the API is doing one item at the time, so if you do many items, it will be slower. 

    For the unregistration of all assets in your project, maybe you could run the tank command with an "assets" filter applied?

댓글을 남기려면 로그인하세요.